home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 2004 #2 / Amiga Plus CD - 2004 - No. 02.iso / AmiSoft / Disk / moni / FileX-src.lha / FileX-src / display.c < prev    next >
C/C++ Source or Header  |  2004-01-07  |  84KB  |  2,166 lines

  1. #include "allprotos.h"
  2. #include "FileXStructs.h"
  3. #include "FileXStrings.h"
  4.  
  5. UBYTE CursorAPen = 2, CursorBPen = 3, CursorLinePen = 2;
  6. UBYTE NormalAPen = 1, NormalBPen = 0;
  7. UBYTE BlockAPen = 3, BlockBPen = 2;
  8.  
  9. void CalcStatusZeilenBreite( struct DisplayData *DD )
  10. {
  11.                 /* Statuszeilenbreite neuberechnen */
  12.  
  13.         DD->StatusZeilenBreite = 9 * DD->DI->fbreite;
  14.  
  15.         if( DD->DisplayForm & DF_HEX )
  16.                 DD->StatusZeilenBreite += (2 * DD->BPR + (( DD->BPR - 1 ) >> DD->DisplaySpaces )) * DD->DI->fbreite + BOXADDX;
  17.         if( DD->DisplayForm & DF_ASCII )
  18.                 DD->StatusZeilenBreite += DD->BPR * DD->DI->fbreite + BOXADDX;
  19. }
  20.  
  21. void InvertStatusBalkenRahmen( struct DisplayData *DD, WORD off )
  22. {
  23.         SetDrMd( DD->Wnd->RPort, COMPLEMENT );
  24.         Move( DD->Wnd->RPort, DD->sbx - BOXADDX/2, DD->sbby - BOXADDY/2 + off * DD->DI->fhöhe );
  25.         Draw( DD->Wnd->RPort, DD->sbx + DD->StatusZeilenBreite + BOXADDX/2 - 1, DD->sbby - BOXADDY/2 + off * DD->DI->fhöhe );
  26.         Draw( DD->Wnd->RPort, DD->sbx + DD->StatusZeilenBreite + BOXADDX/2 - 1, DD->sbby + off * DD->DI->fhöhe + DD->DI->fhöhe + BOXADDY/2 - 1);
  27.         Draw( DD->Wnd->RPort, DD->sbx - BOXADDX/2, DD->sbby + off * DD->DI->fhöhe + DD->DI->fhöhe + BOXADDY/2 - 1);
  28.         Draw( DD->Wnd->RPort, DD->sbx - BOXADDX/2, DD->sbby - BOXADDY/2 + off * DD->DI->fhöhe );
  29.         SetDrMd( DD->Wnd->RPort, JAM2 );
  30. }
  31.  
  32. struct DisplayData *GetroffenerView( WORD x, WORD y, struct DisplayInhalt *DI )
  33. {
  34.         struct DisplayData *DD;
  35.  
  36.         DD = ( struct DisplayData * )DI->DisplayList.lh_Head;
  37.  
  38.         while( DD != ( struct DisplayData * )&DI->DisplayList.lh_Tail )
  39.         {
  40.                 if(( y >= DD->sbby - BOXADDY / 2 ) && ( y < DD->bby + DD->Zeilen * DI->fhöhe + BOXADDY/2 ))
  41.                         break;
  42.                 
  43.                 DD = ( struct DisplayData * )DD->Node.ln_Succ;
  44.         }
  45.  
  46.         if( DD != ( struct DisplayData * )&DI->DisplayList.lh_Tail )
  47.                 return( DD );
  48.         else
  49.                 return( NULL );
  50. }
  51.  
  52. BOOL SetzeCursorMaus( WORD x, WORD y, struct DisplayData *SetDD, struct DisplayInhalt *DI )
  53. {
  54.         struct DisplayData *DD;
  55.         BOOL Success = FALSE;
  56.         BOOL Found = FALSE;
  57.  
  58.         DD = GetroffenerView(x,y,DI);
  59.  
  60.         /*if(( !SetDD ) || ( SetDD == DD ))*/ /*Changed to fix the bottom border crash-bug!*/
  61.         if(DD && (( !SetDD ) || ( SetDD == DD )))
  62.         {
  63.                 WORD xoff,yoff;
  64.  
  65.                 if( y >= DD->bby )
  66.                 {
  67.                         yoff = ( y - DD->bby ) / DI->fhöhe;
  68.  
  69.                         if( yoff < DD->Zeilen )
  70.                         {
  71.                                 if( DD->DisplayForm & DF_ASCII )
  72.                                 {
  73.                                         if( x >= DD->abx )
  74.                                         {
  75.                                                 xoff = ( x - DD->abx ) / DI->fbreite;
  76.                         
  77.                                                 if( xoff < DD->BPR )
  78.                                                 {
  79.                                                         Found = TRUE;
  80.                                                         Success = TRUE;
  81.                                                         SetCursor( yoff * DD->BPR + xoff + DD->SPos * DD->BPR, DD );
  82.  
  83.                                                         if(( DD->Flags & DD_HEX ) && ( !( DD->Flags & DD_MARK )))
  84.                                                                 WechselCursorBereich( DD );
  85.                                                 }
  86.                                         }
  87.                                 }
  88.                                 if(( !Found ) && ( DD->DisplayForm & DF_HEX ))
  89.                                 {
  90.                                         if( x >= DD->hbx )
  91.                                         {
  92.                                                 xoff = ( x - DD->hbx ) / DI->fbreite;
  93.                         
  94.                                                 if( xoff < 2 * DD->BPR + (( DD->BPR - 1 ) >> DD->DisplaySpaces ))
  95.                                                 {
  96.                                                         WORD Rest, HexBlockX;
  97.  
  98.                                                         Found = TRUE;
  99.                                                         HexBlockX = 2 * ( 1 << DD->DisplaySpaces ) + 1;
  100.                         
  101.                                                         Rest = xoff % HexBlockX;
  102.                         
  103.                                                         if( Rest != HexBlockX - 1 )
  104.                                                         {
  105.                                                                 Success = TRUE;
  106.                                                                 SetCursor( yoff * DD->BPR + ( Rest + xoff / HexBlockX * ( HexBlockX - 1 )) / 2 + DD->SPos * DD->BPR, DD );
  107.  
  108.                                                                 if((!( DD->Flags & DD_HEX )) && ( !( DD->Flags & DD_MARK )))
  109.                                                                         WechselCursorBereich( DD );
  110.                                                         }
  111.                                                 }
  112.                                         }
  113.                                 }
  114.                         }
  115.                 }
  116.                 
  117.                 ChangeAktuView( DD );
  118.         }
  119.         
  120.         if( SetDD && ( !Found ))
  121.         {
  122.                 WORD yoff;
  123.  
  124.                 yoff = ( y - SetDD->bby ) / DI->fhöhe;
  125.  
  126.                 MoveCursorY( yoff - ( SetDD->CPos / SetDD->BPR - SetDD->SPos ), SetDD );
  127.         }
  128.  
  129.         return( Success );
  130. }
  131.  
  132. BOOL StatusBalkenHit( WORD x, WORD y, struct DisplayInhalt *DI )
  133. {
  134.         struct DisplayData *DD;
  135.         BOOL Found = FALSE;
  136.  
  137.         DD = ( struct DisplayData * )DI->DisplayList.lh_Head;
  138.  
  139.         while(( DD != ( struct DisplayData * )&DI->DisplayList.lh_Tail ) && ( y >= DD->sbby - BOXADDY / 2 ))
  140.         {
  141.                 if( y < DD->sbby + DI->fhöhe + BOXADDY/2 )
  142.                 {
  143.                         Found = TRUE;
  144.                         break;
  145.                 }
  146.                 
  147.                 DD = ( struct DisplayData * )DD->Node.ln_Succ;
  148.         }
  149.  
  150.         if( Found )
  151.                 ChangeAktuView( DD );
  152.  
  153.         return( Found );
  154. }
  155.  
  156. void MarkOn( struct DisplayData *DD )
  157. {
  158.         ExpandBlock( DD->MPos, DD->MPos, DD );
  159. }
  160.  
  161. void MarkOff( struct DisplayData *DD )
  162. {
  163. //      BlockKürzen( DD->MPos - DD->SPos * DD->BPR, DD->CPos - DD->SPos * DD->BPR, DD);
  164.     RedrawDisplay(DD);
  165. }
  166.  
  167. void MySetWriteMask( struct RastPort *rp, ULONG msk )
  168. {
  169. /*      if( Kick30 ) SetWriteMask( rp, msk );*/
  170. /*      else SetWrMsk( rp, msk );*/
  171. }
  172.  
  173. static void DrawCursor( struct DisplayData *DD )
  174. {
  175.         int off,x,y;
  176.  
  177.         if( DD->FD->Len == 0 ) return;
  178.  
  179. /*      kprintf( "DrawCursor: Pos: %ld\n", DD->CPos );*/
  180.  
  181.         off = DD->CPos - DD->BPR * DD->SPos;
  182.  
  183.         if(( off >= 0 ) && ( off < DD->BPR * DD->Zeilen ))
  184.         {
  185.                 x = off % DD->BPR;
  186.                 y = off / DD->BPR;
  187.         
  188.                 if( DD->Flags & DD_HEX )                        /* Im Hexfeld aktiv */
  189.                 {
  190.                         if( DD->DisplayForm & DF_ASCII )
  191.                         {
  192.                                         /* Buchstaben in normalen Farben malen */
  193. /*
  194.                                 SetAPen( DD->Wnd->RPort, NormalAPen );
  195.                                 SetBPen( DD->Wnd->RPort, NormalBPen );
  196.                 
  197.                                 Move( DD->Wnd->RPort, DD->abx + x * DD->DI->fbreite, DD->Wnd->RPort->Font->tf_Baseline + DD->bby + y * DD->DI->fhöhe );
  198.                                 Text( DD->Wnd->RPort, &displaytab[ DD->DisplayTyp ][ DD->FD->Mem[ DD->CPos ]], 1);
  199. */                                
  200.                                         /* Linie in Cursorfarben drunter setzen */
  201.                 
  202.                                 SetAPen( DD->Wnd->RPort, CursorLinePen );
  203.  
  204.                                 Move( DD->Wnd->RPort, DD->abx + x * DD->DI->fbreite, DD->bby + y * DD->DI->fhöhe + DD->DI->fhöhe - 1 );
  205.                                 Draw( DD->Wnd->RPort, DD->abx + x * DD->DI->fbreite + DD->DI->fbreite - 1, DD->bby + DD->DI->fhöhe * y + DD->DI->fhöhe - 1 );
  206.                         }
  207.  
  208.                         if( DD->DisplayForm & DF_HEX )
  209.                         {
  210.                                 char text[ 2 ];
  211.                         
  212.                                 ByteToString( DD->FD->Mem[ DD->CPos ], text );
  213.                                 
  214.                                 x = 2 * x + ( x >> DD->DisplaySpaces );
  215.                                         
  216.                                 SetAPen( DD->Wnd->RPort, CursorAPen );
  217.                                 SetBPen( DD->Wnd->RPort, CursorBPen );
  218.                                 Move( DD->Wnd->RPort, DD->hbx + x * DD->DI->fbreite, DD->Wnd->RPort->Font->tf_Baseline + DD->bby + y * DD->DI->fhöhe );
  219.                                 Text( DD->Wnd->RPort, text, 2 );
  220.                         }
  221.                 }
  222.                 else                                                                    /* Im ASCII-Feld aktiv */
  223.                 {
  224.                         if( DD->DisplayForm & DF_ASCII )
  225.                         {
  226.                                 SetAPen( DD->Wnd->RPort, CursorAPen );
  227.                                 SetBPen( DD->Wnd->RPort, CursorBPen );
  228.                         
  229.                                 Move( DD->Wnd->RPort, DD->abx + x * DD->DI->fbreite, DD->Wnd->RPort->Font->tf_Baseline + DD->bby + y * DD->DI->fhöhe );
  230.                                 Text( DD->Wnd->RPort, &displaytab[ DD->DisplayTyp ][ DD->FD->Mem[ DD->CPos ]], 1);
  231.                         }
  232.         
  233.                         if( DD->DisplayForm & DF_HEX )
  234.                         {
  235.                                 char text[ 2 ];
  236.                         
  237.                                 ByteToString( DD->FD->Mem[ DD->CPos ], text );
  238.                                 
  239.                                 x = 2 * x + ( x >> DD->DisplaySpaces );
  240. /*                                        
  241.                                 SetAPen( DD->Wnd->RPort, NormalAPen );
  242.                                 SetBPen( DD->Wnd->RPort, NormalBPen );
  243.                                 Move( DD->Wnd->RPort, DD->hbx + x * DD->DI->fbreite, DD->Wnd->RPort->Font->tf_Baseline + DD->bby + y * DD->DI->fhöhe );
  244.                                 Text( DD->Wnd->RPort, text, 2 );
  245. */
  246.                                 SetAPen( DD->Wnd->RPort, CursorLinePen );
  247.                                 Move( DD->Wnd->RPort, DD->hbx + x * DD->DI->fbreite, DD->bby + y * DD->DI->fhöhe + DD->DI->fhöhe - 1 );
  248.                                 Draw( DD->Wnd->RPort, DD->hbx + x * DD->DI->fbreite + 2 * DD->DI->fbreite - 1, DD->bby + y * DD->DI->fhöhe + DD->DI->fhöhe - 1 );
  249.                         }
  250.                 }
  251.         SetAPen( DD->Wnd->RPort, NormalAPen );
  252.                 SetBPen( DD->Wnd->RPort, NormalBPen );
  253.         }
  254. }
  255.  
  256. /*
  257.  * void CursorOn(void)
  258.  *
  259.  * Füllt ein Rechteck an der aktuellen Position in der Größe des Cursors
  260.  *           und einen Strich im anderen Feld, je nachdem
  261.  *           wie in cursorflags gesetzt
  262.  * unter der Bed., daß die Länge der Daten > 0
  263.  */
  264.  
  265. void CursorOn( struct DisplayData *DD )
  266. {
  267. /*      kprintf( "CursorOn:" );*/
  268.  
  269.         DrawCursor( DD );
  270. }
  271.  
  272. /*
  273.  * void CursorOff(void)
  274.  *
  275.  */
  276.  
  277. void CursorOff( struct DisplayData *DD )
  278. {
  279.         int off,x,y;
  280.  
  281.         if( DD->FD->Len == 0 ) return;
  282.  
  283.         off = DD->CPos - DD->BPR * DD->SPos;
  284.  
  285.         if(( off >= 0 ) && ( off < DD->BPR * DD->Zeilen ))
  286.         {
  287.                 x = off % DD->BPR;
  288.                 y = off / DD->BPR;
  289.         
  290.                 if( DD->DisplayForm & DF_ASCII )
  291.                 {
  292.                                 /* Buchstaben in normalen Farben malen */
  293.  
  294.                         SetAPen( DD->Wnd->RPort, NormalAPen );
  295.                         SetBPen( DD->Wnd->RPort, NormalBPen );
  296.         
  297.                         Move( DD->Wnd->RPort, DD->abx + x * DD->DI->fbreite, DD->Wnd->RPort->Font->tf_Baseline + DD->bby + y * DD->DI->fhöhe );
  298.                         Text( DD->Wnd->RPort, &displaytab[ DD->DisplayTyp ][ DD->FD->Mem[ DD->CPos ]], 1);
  299.                 }
  300.  
  301.                 if( DD->DisplayForm & DF_HEX )
  302.                 {
  303.                         char text[ 2 ];
  304.                 
  305.                         ByteToString( DD->FD->Mem[ DD->CPos ], text );
  306.                         
  307.                         x = 2 * x + ( x >> DD->DisplaySpaces );
  308.                                 
  309.                         SetAPen( DD->Wnd->RPort, NormalAPen );
  310.                         SetBPen( DD->Wnd->RPort, NormalBPen );
  311.                         Move( DD->Wnd->RPort, DD->hbx + x * DD->DI->fbreite, DD->Wnd->RPort->Font->tf_Baseline + DD->bby + y * DD->DI->fhöhe );
  312.                         Text( DD->Wnd->RPort, text, 2 );
  313.                 }
  314.         }
  315. }
  316.  
  317. static void BlockZeichnen( long start, long end, BOOL ClearSpaces, struct DisplayData *DD )
  318. {
  319.         long startx, starty, endx, endy;
  320.  
  321.         if( start > end ) { long dummy = start; start = end; end = dummy; }
  322.  
  323.         if( start < 0 ) start = 0;
  324.         if( end >= DD->BPR * DD->Zeilen ) end = DD->BPR * DD->Zeilen - 1;
  325.  
  326. /*      Printf( "BlockZeichnen( %ld, %ld, %ld)\n", start, end, ClearSpaces );*/
  327.  
  328.         startx = start % DD->BPR;
  329.         starty = start / DD->BPR;
  330.         endx = end % DD->BPR;
  331.         endy = end / DD->BPR;
  332.  
  333.         MySetWriteMask( DD->Wnd->RPort, 2 );
  334.  
  335.                 /* Gleiche Zeile ? */
  336.  
  337.         if( DD->DisplayForm & DF_HEX )
  338.         {
  339.                 if( starty == endy )
  340.                 {
  341.                         RectFill( DD->Wnd->RPort,       DD->hbx + ( 2 * startx + ( startx >> DD->DisplaySpaces )) * DD->DI->fbreite,
  342.                                                                 DD->bby + starty * DD->DI->fhöhe,
  343.                                                                 DD->hbx + ( 2 * endx + ( endx >> DD->DisplaySpaces  )) * DD->DI->fbreite + DD->DI->fbreite * 2 - 1,
  344.                                                                 DD->bby + starty * DD->DI->fhöhe + DD->DI->fhöhe - 1 );
  345.                 }
  346.                 else
  347.                 {
  348.                                 /* 3 Schritte: 1. Startzeile bis zum Ende markieren */
  349.                                 /*             2. ggf. ZwischenZeilen markieren */
  350.                                 /*             3. Endzeile von Anfang bis Endmarke markieren */
  351.         
  352.                         RectFill(DD->Wnd->RPort,        DD->hbx + ( 2 * startx + ( startx >> DD->DisplaySpaces )) * DD->DI->fbreite,
  353.                                                                 DD->bby + starty * DD->DI->fhöhe,
  354.                                                                 DD->hbx + ( 2 * DD->BPR + (( DD->BPR - 1 ) >> DD->DisplaySpaces )) * DD->DI->fbreite - 1,
  355.                                                                 DD->bby + starty * DD->DI->fhöhe + DD->DI->fhöhe - 1 );
  356.         
  357.                         if(( endy - starty ) > 1 )
  358.                         {
  359.                                 RectFill(DD->Wnd->RPort,        DD->hbx,
  360.                                                                         DD->bby + ( starty + 1 ) * DD->DI->fhöhe,
  361.                                                                         DD->hbx + ( 2 * DD->BPR + (( DD->BPR - 1 ) >> DD->DisplaySpaces )) * DD->DI->fbreite - 1,
  362.                                                                         DD->bby + ( endy - 1 ) * DD->DI->fhöhe + DD->DI->fhöhe - 1 );
  363.                         }
  364.         
  365.                         RectFill(DD->Wnd->RPort,        DD->hbx,
  366.                                                                 DD->bby + endy * DD->DI->fhöhe,
  367.                                                                 DD->hbx + ( 2 * endx + ( endx >> DD->DisplaySpaces  )) * DD->DI->fbreite + DD->DI->fbreite * 2 - 1,
  368.                                                                 DD->bby + endy * DD->DI->fhöhe + DD->DI->fhöhe - 1 );
  369.         
  370.                 }
  371.  
  372.                 if( ClearSpaces )
  373.                 {
  374.                                 /* Prüfen, ob einer der Randpunkte an einer Hexfeldgrenze liegt */
  375.                 
  376.                         if(( startx > 0 ) && ( startx % ( 1 << DD->DisplaySpaces ) == 0 ))
  377.                         {
  378.                                         /* Feld links daneben löschen */
  379.                 
  380.                                 RectFill(DD->Wnd->RPort,        DD->hbx + ( 2 * startx + ( startx >> DD->DisplaySpaces )) * DD->DI->fbreite - DD->DI->fbreite,
  381.                                                                         DD->bby + starty * DD->DI->fhöhe,
  382.                                                                         DD->hbx + ( 2 * startx + ( startx >> DD->DisplaySpaces )) * DD->DI->fbreite - 1,
  383.                                                                         DD->bby + starty * DD->DI->fhöhe + DD->DI->fhöhe - 1 );
  384.                         }
  385.  
  386.                         if(( endx < DD->BPR - 1 ) && ( endx % ( 1 << DD->DisplaySpaces ) == ( 1 << DD->DisplaySpaces ) - 1 ))
  387.                         {
  388.                                         /* Feld rechts daneben löschen */
  389.                 
  390.                                 RectFill(DD->Wnd->RPort,        DD->hbx + ( 2 + 2 * endx + ( endx >> DD->DisplaySpaces )) * DD->DI->fbreite,
  391.                                                                         DD->bby + endy * DD->DI->fhöhe,
  392.                                                                         DD->hbx + ( 2 + 2 * endx + ( endx >> DD->DisplaySpaces )) * DD->DI->fbreite + DD->DI->fbreite - 1,
  393.                                                                         DD->bby + endy * DD->DI->fhöhe + DD->DI->fhöhe - 1 );
  394.                         }
  395.                 }
  396.         }
  397.  
  398.         if( DD->DisplayForm & DF_ASCII )
  399.         if( starty == endy )
  400.         {
  401.                 RectFill( DD->Wnd->RPort,       DD->abx + startx * DD->DI->fbreite,
  402.                                                         DD->bby + starty * DD->DI->fhöhe,
  403.                                                         DD->abx + endx * DD->DI->fbreite + DD->DI->fbreite - 1,
  404.                                                         DD->bby + starty * DD->DI->fhöhe + DD->DI->fhöhe - 1 );
  405.         }
  406.         else
  407.         {
  408.                         /* 3 Schritte: 1. Startzeile bis zum Ende markieren */
  409.                         /*             2. ggf. ZwischenZeilen markieren */
  410.                         /*             3. Endzeile von Anfang bis Endmarke markieren */
  411.  
  412.                 RectFill(DD->Wnd->RPort,        DD->abx + startx * DD->DI->fbreite,
  413.                                                         DD->bby + starty * DD->DI->fhöhe,
  414.                                                         DD->abx + DD->BPR * DD->DI->fbreite - 1,
  415.                                                         DD->bby + starty * DD->DI->fhöhe + DD->DI->fhöhe - 1 );
  416.  
  417.                 if(( endy - starty ) > 1 )
  418.                 {
  419.                         RectFill(DD->Wnd->RPort,        DD->abx,
  420.                                                                 DD->bby + ( starty + 1 ) * DD->DI->fhöhe,
  421.                                                                 DD->abx + DD->BPR * DD->DI->fbreite - 1,
  422.                                                                 DD->bby + ( endy - 1 ) * DD->DI->fhöhe + DD->DI->fhöhe - 1 );
  423.                 }
  424.  
  425.                 RectFill(DD->Wnd->RPort,        DD->abx,
  426.                                                         DD->bby + endy * DD->DI->fhöhe,
  427.                                                         DD->abx + endx * DD->DI->fbreite + DD->DI->fbreite - 1,
  428.                                                         DD->bby + endy * DD->DI->fhöhe + DD->DI->fhöhe - 1 );
  429.         }
  430.  
  431.         MySetWriteMask( DD->Wnd->RPort, 0xff );
  432. }
  433.  
  434. void BlockKürzen( long start, long end, struct DisplayData *DD )
  435. {
  436.         SetAPen( DD->Wnd->RPort, 0 );
  437.  
  438.         BlockZeichnen( start, end, TRUE, DD );
  439.  
  440.         SetAPen( DD->Wnd->RPort, 1 );
  441. }
  442.  
  443. void BlockErweitern( long start, long end, struct DisplayData *DD )
  444. {
  445.         SetAPen( DD->Wnd->RPort, 2 );
  446.  
  447.         BlockZeichnen( start, end, FALSE, DD );
  448.  
  449.         SetAPen( DD->Wnd->RPort, 1 );
  450. }
  451.  
  452. void ChangeMark(long pos1,long pos2,long off1,long off2, struct DisplayData *DD )
  453. {
  454.         long m1,m2;                                     /* Hilfsmarken, rel. Pos vorher/nachher */
  455.  
  456.  
  457.         m1=pos2-off2*DD->BPR;                   /* vorher! */
  458.         m2=pos1-off1*DD->BPR;                   /* Bytes zum Ausschnittanfang (nachher)*/
  459.  
  460. /*kprintf("p1:%ld,p2:%ld,off1:%ld,Off2:%ld,m1:%ld, m2:%ld\n", pos1, pos2, off1, off2,m1, m2 );*/
  461.  
  462.         if((pos1==pos2)&&(off1==off2))return;
  463.  
  464.                 /* Wechsel von Start und Ende? */
  465.  
  466.         if((((pos2>=DD->MPos)&&(pos1>=DD->MPos))||
  467.                 ((pos2<=DD->MPos)&&(pos1<=DD->MPos))))
  468.         {
  469.                 long start,end;
  470.  
  471.                 if(pos2<DD->MPos)
  472.                 {
  473.                         start=pos2;
  474.                         end=DD->MPos;
  475.                 }
  476.                 else
  477.                 {
  478.                         start=DD->MPos;
  479.                         end=pos2;
  480.                 }
  481.  
  482.                 if(off2!=off1)  /* Wurde gescrollt ? */
  483.                 {
  484.                 if(off2<off1)           /* Nach oben */
  485.                 {
  486.  
  487.                                         /* Prüfen, ob alte DD->CPos inner- oder außerhalb */
  488.  
  489.                         if((pos1>=start)&&(pos1<=end))          /* Innerhalb */
  490.                         {
  491.                                         /* Gleiche Position */
  492.  
  493.                                 if( pos1 == pos2 )
  494.                                 {
  495.                                         if( DD->MPos < pos2 )
  496.                                                 BlockErweitern( m1, m2, DD );
  497.                                         else
  498.                                                 BlockKürzen( m2, m1 - 1, DD );
  499.                                 }
  500.                                 else
  501.                                 {
  502.                                 /* Falls vorne eine Änderung nötig, ändern */
  503.  
  504.                                 if(m1!=m2)
  505.                                 {
  506.                                         if(m1>m2) BlockKürzen( m2, m1 - 1, DD );
  507.                                         else BlockErweitern( m1, m2, DD );
  508.                                 }
  509.  
  510.                                 /* Falls noch nicht alles gefüllt ist */
  511.                                 /* Block erweitern */
  512.  
  513.                                 if(end<(off1+DD->Zeilen)*DD->BPR)
  514.                                 {
  515.                                         start=end-off1*DD->BPR;
  516.                                         end-=off2*DD->BPR;
  517.  
  518.                                         if(end>=DD->Zeilen*DD->BPR)end=DD->Zeilen*DD->BPR-1;
  519.                                         if(pos2-off2*DD->BPR > start) start = pos2-off2*DD->BPR;
  520.  
  521.                                         BlockErweitern( start, end, DD );
  522.                                 }
  523.                                 }
  524.                         }
  525.                         else                    /* Außerhalb */
  526.                         {
  527.                                 if(m1!=m2)
  528.                                 {
  529.                                         if(m1<m2) BlockKürzen( m1 + 1, m2, DD );
  530.                                         else BlockErweitern( m2, m1, DD );
  531.                                 }
  532.  
  533.                                 if(start>DD->BPR*off2)
  534.                                 {
  535.                                         end=start-1-off2*DD->BPR;
  536.                                         start-=off1*DD->BPR;
  537.  
  538.                                         if(start<0)start=0;
  539.  
  540.                                         BlockKürzen( start, end, DD );
  541.                                 }
  542.                         }
  543.                 }
  544.                 else                    /* Nach Unten gescrollt */
  545.                 {
  546.                         if((pos1>=start)&&(pos1<=end))  /* Innerhalb */
  547.                         {
  548.                                                 /* Keine Cursorverschiebung */
  549.  
  550.                                 if( pos1 == pos2 )
  551.                                 {
  552.                                         if( DD->MPos > pos2 )
  553.                                                 BlockErweitern( m1, m2, DD );
  554.                                         else
  555.                                                 BlockKürzen( m2, m1 + 1, DD );
  556.                                 }
  557.                                 else
  558.                                 {
  559.  
  560.                                 if(m1!=m2)
  561.                                 {
  562.                                         if(m1<m2) BlockKürzen( m1 + 1, m2, DD );
  563.                                         else BlockErweitern( m2, m1, DD );
  564.                                 }
  565.  
  566.                                 if(start>off1*DD->BPR)
  567.                                 {
  568.                                         end=start-off1*DD->BPR;
  569.                                         start-=off2*DD->BPR;
  570.  
  571.                                         if(start<0)start=0;
  572.                                         if(pos2-off2*DD->BPR < end) end = pos2-off2*DD->BPR;
  573.  
  574.                                         BlockErweitern( start, end, DD );
  575.                                 }
  576.                                 }
  577.                         }
  578.                         else
  579.                         {
  580.                                         /* Außerhalb */
  581.  
  582.                                 if(m1!=m2)
  583.                                 {
  584.                                         if(m1>m2) BlockKürzen( m2, m1 - 1, DD );
  585.                                         else BlockErweitern( m1, m2, DD );
  586.                                 }
  587.  
  588.                                 if(end<DD->BPR*(off2+DD->Zeilen))
  589.                                 {
  590.                                         start=end+1-off2*DD->BPR;
  591.                                         end-=off1*DD->BPR;
  592.  
  593.                                         if(end>=DD->Zeilen*DD->BPR)end=DD->Zeilen*DD->BPR-1;
  594.  
  595.                                         BlockKürzen( start, end, DD );
  596.                                 }
  597.                         }
  598.                 }
  599.                 }
  600.                 else                    /* Er wurde nicht gescrollt */
  601.                 {
  602.                         /* Falls Alte Pos innerhalb der neuen Markierung, Marke erweitern */
  603.                         /* sonst, Marke kürzen */
  604.  
  605.                         if((pos1>=start)&&(pos1<=end))
  606.                         {
  607.                                 if(pos1<pos2) start=pos1;
  608.                                 else end=pos1;
  609.  
  610.                                 start-=off2*DD->BPR;
  611.                                 end-=off2*DD->BPR;
  612.  
  613.                                 BlockErweitern( start, end, DD );
  614.                         }
  615.                         else
  616.                         {
  617.                                 if(pos1>end)
  618.                                 {
  619.                                         start=end+1;
  620.                                         end=pos1;
  621.                                 }
  622.                                 else
  623.                                 {
  624.                                         end=start-1;
  625.                                         start=pos1;
  626.                                 }
  627.  
  628.                                 start-=off2*DD->BPR;
  629.                                 end-=off2*DD->BPR;
  630.  
  631.                                 BlockKürzen( start, end, DD );
  632.                         }
  633.                 }
  634.         }
  635.         else    /* Wechsel von Start und End, alten Bereich löschen und neuen zeichnen */
  636.         {
  637.                 BlockKürzen( m2, DD->MPos - off1 * DD->BPR, DD );
  638.                 BlockErweitern( m1, DD->MPos - off2 * DD->BPR, DD );
  639.         }
  640. }
  641.  
  642.  
  643. /*
  644.  * void ByteToString(UBYTE num,UBYTE *string)
  645.  *
  646.  * Wandelt num in 2 hexadezimal Zeichen und fügt diese in string ein
  647.  */
  648.  
  649. __inline void ByteToString(UBYTE num,UBYTE *string)
  650. {
  651.         *string++ = hexarray[ num >> 4 ];
  652.         *string = hexarray[ num & 0xf ];
  653. }
  654.  
  655. void MyText( struct RastPort *rp, WORD x, WORD y, char *text, LONG len )
  656. {
  657.         Move( &TempRP, 0, rp->Font->tf_Baseline );
  658.         Text( &TempRP, text, len );
  659.         ClipBlit( &TempRP, 0, 0, rp, x, y, len * rp->Font->tf_XSize, rp->Font->tf_YSize, 0xc0 );
  660. }
  661.  
  662.  
  663. /*
  664.  * static void DisplayZeilen( long von, long bis, long pos, struct DisplayData *DD )
  665.  *
  666.  * Stellt die Daten in den Zeilen von-bis ab pos in einem View dar.
  667.  */
  668.  
  669. void DisplayZeilen( long von, long bis, long pos, struct DisplayData *DD )
  670. {
  671.         UBYTE mtext[ 10 ];
  672.         long ypos;
  673.         ULONG ap;
  674.         long k,t;
  675.         long offset=0;
  676.  
  677.         if( DD->FD->Typ == FD_GRAB ) offset = ( long )DD->FD->Mem;
  678.  
  679.         mtext[8] = ':';
  680.  
  681.         for(t = von, ypos = DD->bby + DD->DI->fbase + t * DD->DI->fhöhe, ap = ( pos + t ) * DD->BPR;
  682.                         t < bis;
  683.                         t++, ypos += DD->DI->fhöhe, ap += DD->BPR)
  684.         {
  685.                 {
  686.                         register UBYTE *ptr = mtext + 7;
  687.                         register ULONG aap = ap + offset;
  688.  
  689.                         *ptr--=hexarray[ aap           & 0xf];
  690.                         *ptr--=hexarray[(aap = aap>>4) & 0xf];
  691.                         *ptr--=hexarray[(aap = aap>>4) & 0xf];
  692.                         *ptr--=hexarray[(aap = aap>>4) & 0xf];
  693.                         *ptr--=hexarray[(aap = aap>>4) & 0xf];
  694.                         *ptr--=hexarray[(aap = aap>>4) & 0xf];
  695.                         *ptr--=hexarray[(aap = aap>>4) & 0xf];
  696.                         *ptr  =hexarray[(      aap>>4) & 0xf];
  697.  
  698.                         Move( DD->Wnd->RPort, DD->mbx, ypos);
  699.                         Text( DD->Wnd->RPort, mtext, 9);
  700.                 }
  701.  
  702.                 if( DD->DisplayForm & DF_HEX )
  703.                 {
  704.                         register unsigned char *ptr = TextLineBuffer;
  705.                         register unsigned char *memptr = DD->FD->Mem + ap;
  706.  
  707.                         for( k = 0; k < DD->BPR; k++ )
  708.                         {
  709.                                 *ptr++ = hexarray[*memptr >>  4];
  710.                                 *ptr++ = hexarray[*memptr++ & 0xf];
  711.  
  712.                                 if(( k >> DD->DisplaySpaces ) != (( k + 1 ) >> DD->DisplaySpaces)) *ptr++ = ' ';
  713.                         }
  714.  
  715.                         if( ap + DD->BPR > DD->FD->Len )
  716.                         {
  717.                                 ptr = TextLineBuffer + 2 * ( DD->FD->Len - ap ) + (( DD->FD->Len - ap ) >> DD->DisplaySpaces );
  718.  
  719.                                 while( ptr < ( unsigned char * )TextLineBuffer + 2 * DD->BPR + (( DD->BPR - 1 ) >> DD->DisplaySpaces ))
  720.                                         *ptr++ = ' ';
  721.                         }
  722.  
  723. MyText( DD->Wnd->RPort, DD->hbx, ypos - DD->DI->fbase, TextLineBuffer, 2 * DD->BPR + (( DD->BPR - 1 ) >> DD->DisplaySpaces ));
  724. /*Move( &TempRP, 0, DD->DI->fbase );*/
  725. /*Text( &TempRP, TextLineBuffer, 2 * DD->BPR + (( DD->BPR - 1 ) >> DD->DisplaySpaces ));*/
  726. /*ClipBlit( &TempRP, 0,0, DD->Wnd->RPort, DD->hbx, ypos - DD->DI->fbase, (2 * DD->BPR + (( DD->BPR - 1 ) >> DD->DisplaySpaces )) * DD->DI->fbreite, DD->DI->fhöhe, 0xc0 );*/
  727. /*                      Move( DD->Wnd->RPort, DD->hbx, ypos );*/
  728. /*                      Text( DD->Wnd->RPort, TextLineBuffer, 2 * DD->BPR + (( DD->BPR - 1 ) >> DD->DisplaySpaces ));*/
  729.                 }
  730.  
  731.                 if( DD->DisplayForm & DF_ASCII )
  732.                 {
  733.                         register unsigned char *ptr = TextLineBuffer;
  734.                         register unsigned char *memptr = DD->FD->Mem+ap;
  735.  
  736.  
  737.                         for( k = 0; k < DD->BPR; k++ )
  738.                                 *ptr++ = displaytab[ DD->DisplayTyp ][ *memptr++ ];
  739.                         
  740.                                 /* Falls letzte Zeile */
  741.  
  742.                         if( ap + DD->BPR > DD->FD->Len)
  743.                         {
  744.                                 ptr = TextLineBuffer + DD->FD->Len - ap;
  745.  
  746.                                 while( ptr < ( unsigned char * )TextLineBuffer + DD->BPR)
  747.                                         *ptr++ = ' ';
  748.                         }
  749.  
  750. MyText( DD->Wnd->RPort, DD->abx, ypos - DD->DI->fbase, TextLineBuffer, DD->BPR );
  751. /*Move( &TempRP, 0, DD->DI->fbase );*/
  752. /*Text( &TempRP, TextLineBuffer, DD->BPR );*/
  753. /*ClipBlit( &TempRP, 0,0, DD->Wnd->RPort, DD->abx, ypos - DD->DI->fbase, DD->BPR * DD->DI->fbreite, DD->DI->fhöhe, 0xc0 );*/
  754. /*                      Move( DD->Wnd->RPort, DD->abx, ypos );*/
  755. /*                      Text( DD->Wnd->RPort, TextLineBuffer, DD->BPR );*/
  756.                 }
  757.         }
  758. }
  759.  
  760. void DrawAddresses( long von, long bis, struct DisplayData *DD )
  761. {
  762.         UBYTE mtext[ 10 ];
  763.         long offset=0;
  764.         long ypos;
  765.         ULONG ap;
  766.  
  767.     SetAPen( DD->Wnd->RPort, NormalAPen );
  768.         SetBPen( DD->Wnd->RPort, NormalBPen );
  769.  
  770.         if( DD->FD->Typ == FD_GRAB ) offset = ( long )DD->FD->Mem;
  771.  
  772.         ypos = DD->bby + DD->DI->fbase + von * DD->DI->fhöhe;
  773.         ap = ( DD->SPos + von ) * DD->BPR;
  774.  
  775.         mtext[8] = ':';
  776.  
  777.         while( von <= bis )
  778.         {
  779.                 register UBYTE *ptr = mtext + 7;
  780.                 register ULONG aap = ap + offset;
  781.  
  782.                 *ptr--=hexarray[ aap           & 0xf];
  783.                 *ptr--=hexarray[(aap = aap>>4) & 0xf];
  784.                 *ptr--=hexarray[(aap = aap>>4) & 0xf];
  785.                 *ptr--=hexarray[(aap = aap>>4) & 0xf];
  786.                 *ptr--=hexarray[(aap = aap>>4) & 0xf];
  787.                 *ptr--=hexarray[(aap = aap>>4) & 0xf];
  788.                 *ptr--=hexarray[(aap = aap>>4) & 0xf];
  789.                 *ptr  =hexarray[(      aap>>4) & 0xf];
  790.  
  791.                 Move( DD->Wnd->RPort, DD->mbx, ypos);
  792.                 Text( DD->Wnd->RPort, mtext, 9);
  793.                 
  794.                 von++;
  795.                 ypos += DD->DI->fhöhe;
  796.                 ap += DD->BPR;
  797.         }
  798. }
  799.  
  800. /*
  801.  * void DisplayPart( long von, long bis, struct DisplayData *DD )
  802.  *
  803.  * Stellt die Daten von bis in einem View *neu* dar.
  804.  * Aktuelle Farben werden berücksichtigt.
  805.  */
  806.  
  807. void DisplayPart( long von, long bis, struct DisplayData *DD )
  808. {
  809.         long ypos;
  810.         long k,t;
  811.         long startzeile, endzeile;
  812.         long HexZeilenBreite;
  813.     UBYTE *BufferEnd;
  814.  
  815.     BufferEnd=DD->FD->Mem+DD->FD->Len;
  816.         HexZeilenBreite = 2 * DD->BPR + (( DD->BPR - 1 ) >> DD->DisplaySpaces );
  817.  
  818.         startzeile = von / DD->BPR;
  819.         endzeile = bis / DD->BPR;
  820.  
  821.         ypos = DD->bby + DD->DI->fbase + startzeile * DD->DI->fhöhe;
  822.  
  823.         if( startzeile == endzeile )
  824.         {
  825.                 if( DD->DisplayForm & DF_HEX )
  826.                 {
  827.                         register unsigned char *ptr = TextLineBuffer;
  828.                         register unsigned char *memptr = DD->FD->Mem + ( DD->SPos + startzeile ) * DD->BPR ;
  829.                         long startoff;
  830.  
  831.                         for( k = 0; k < DD->BPR; k++ )
  832.                         {
  833.                 if (memptr<BufferEnd)
  834.                 {
  835.                                     *ptr++ = hexarray[*memptr >>  4];
  836.                                     *ptr++ = hexarray[*memptr++ & 0xf];
  837.                 }
  838.                 else
  839.                 {
  840.                     *ptr++=' ';
  841.                     *ptr++=' ';
  842.                 }
  843.  
  844.                                 if(( k >> DD->DisplaySpaces ) != (( k + 1 ) >> DD->DisplaySpaces)) *ptr++ = ' ';
  845.                         }
  846.  
  847.                         if( von % DD->BPR )
  848.                         {
  849.                                 startoff = ( von % DD->BPR ) * 2 + (( von % DD->BPR - 1 ) >> DD->DisplaySpaces );
  850.                         }
  851.                         else
  852.                                 startoff = 0;
  853.  
  854.                         Move( DD->Wnd->RPort, DD->hbx + startoff * DD->DI->fbreite, ypos );
  855.             if (memptr==BufferEnd)
  856.                 Text( DD->Wnd->RPort, TextLineBuffer + startoff, HexZeilenBreite - startoff);
  857.             else
  858.                             Text( DD->Wnd->RPort, TextLineBuffer + startoff, ( bis % DD->BPR + 1 ) * 2 + (( bis % DD->BPR - 1 + 1 ) >> DD->DisplaySpaces ) - startoff);
  859.                 }
  860.  
  861.                 if( DD->DisplayForm & DF_ASCII )
  862.                 {
  863.                         register unsigned char *ptr = TextLineBuffer;
  864.                         register unsigned char *memptr = DD->FD->Mem + ( DD->SPos + startzeile ) * DD->BPR;
  865.                         long startoff;
  866.  
  867.                         for( k = 0; k < DD->BPR; k++ )
  868.                 if (memptr<BufferEnd)
  869.                                     *ptr++ = displaytab[ DD->DisplayTyp ][ *memptr++ ];
  870.                 else
  871.                     *ptr++=' ';
  872.                         
  873.                         startoff = von % DD->BPR;
  874.                         
  875.                         Move( DD->Wnd->RPort, DD->abx + startoff * DD->DI->fbreite, ypos );
  876.             if (memptr==BufferEnd)
  877.                 Text( DD->Wnd->RPort, TextLineBuffer + startoff, DD->BPR - startoff );
  878.             else
  879.                             Text( DD->Wnd->RPort, TextLineBuffer + startoff, bis % DD->BPR + 1 - startoff );
  880.                 }
  881.         }
  882.         else
  883.         {
  884.                         /* Startzeile neu darstellen */
  885.  
  886.                 if( von % DD->BPR != 0 )
  887.                 {
  888.                         if( DD->DisplayForm & DF_HEX )
  889.                         {
  890.                                 register unsigned char *ptr = TextLineBuffer;
  891.                                 register unsigned char *memptr = DD->FD->Mem + ( DD->SPos + startzeile ) * DD->BPR ;
  892.                                 long startoff;
  893.         
  894.                                 for( k = 0; k < DD->BPR; k++ )
  895.                                 {
  896.                                     *ptr++ = hexarray[*memptr >>  4];
  897.                                     *ptr++ = hexarray[*memptr++ & 0xf];
  898.         
  899.                                         if(( k >> DD->DisplaySpaces ) != (( k + 1 ) >> DD->DisplaySpaces)) *ptr++ = ' ';
  900.                                 }
  901.  
  902.                                 startoff = ( von % DD->BPR ) * 2 + (( von % DD->BPR - 1 ) >> DD->DisplaySpaces );
  903.         
  904.                                 Move( DD->Wnd->RPort, DD->hbx + startoff * DD->DI->fbreite, ypos );
  905.                                 Text( DD->Wnd->RPort, TextLineBuffer + startoff, HexZeilenBreite - startoff );
  906.                         }
  907.         
  908.                         if( DD->DisplayForm & DF_ASCII )
  909.                         {
  910.                                 register unsigned char *ptr = TextLineBuffer;
  911.                                 register unsigned char *memptr = DD->FD->Mem + ( DD->SPos + startzeile ) * DD->BPR;
  912.                                 long startoff;
  913.         
  914.                                 for( k = 0; k < DD->BPR; k++ )
  915.                                         *ptr++ = displaytab[ DD->DisplayTyp ][ *memptr++ ];
  916.                                 
  917.                                 startoff = von % DD->BPR;
  918.                                 
  919.                                 Move( DD->Wnd->RPort, DD->abx + startoff * DD->DI->fbreite, ypos );
  920.                                 Text( DD->Wnd->RPort, TextLineBuffer + startoff, DD->BPR - startoff );
  921.                         }
  922.         
  923.                         ypos += DD->DI->fhöhe;
  924.                 }
  925.                 else
  926.                 {
  927.                         startzeile--;
  928.                 }
  929.  
  930.                 if( bis % DD->BPR == 15 )
  931.                         endzeile++;
  932.         
  933.                         /* Ggf. Mittelteil neu darstellen */
  934.  
  935.                 if( endzeile - startzeile > 1 )
  936.                 {
  937.                         char *mem = DD->FD->Mem + ( DD->SPos + startzeile + 1 ) * DD->BPR;
  938.  
  939.                         for( t = startzeile + 1; t < endzeile;  t++ )
  940.                         {
  941.                                 if( DD->DisplayForm & DF_HEX )
  942.                                 {
  943.                                         register unsigned char *ptr = TextLineBuffer;
  944.                                         register unsigned char *memptr = mem;
  945.                 
  946.                                         for( k = 0; k < DD->BPR; k++ )
  947.                                         {
  948.                                             *ptr++ = hexarray[*memptr >>  4];
  949.                                             *ptr++ = hexarray[*memptr++ & 0xf];
  950.                 
  951.                                                 if(( k >> DD->DisplaySpaces ) != (( k + 1 ) >> DD->DisplaySpaces)) *ptr++ = ' ';
  952.                                         }
  953.  
  954.                                         Move( DD->Wnd->RPort, DD->hbx, ypos );
  955.                                         Text( DD->Wnd->RPort, TextLineBuffer, HexZeilenBreite );
  956.                                 }
  957.                 
  958.                                 if( DD->DisplayForm & DF_ASCII )
  959.                                 {
  960.                                         register unsigned char *ptr = TextLineBuffer;
  961.                                         register unsigned char *memptr = mem;
  962.                 
  963.                                         for( k = 0; k < DD->BPR; k++ )
  964.                                                 *ptr++ = displaytab[ DD->DisplayTyp ][ *memptr++ ];
  965.  
  966.                                         Move( DD->Wnd->RPort, DD->abx, ypos );
  967.                                         Text( DD->Wnd->RPort, TextLineBuffer, DD->BPR );
  968.                                 }
  969.  
  970.                                 ypos += DD->DI->fhöhe;
  971.                                 mem += DD->BPR;
  972.                         }
  973.                 }
  974.                 
  975.                         /* Endzeile neu darstellen */
  976.  
  977.                 if( bis % DD->BPR != 15 )
  978.                 {
  979.                         if( DD->DisplayForm & DF_HEX )
  980.                         {
  981.                                 register unsigned char *ptr = TextLineBuffer;
  982.                                 register unsigned char *memptr = DD->FD->Mem + ( DD->SPos + endzeile ) * DD->BPR ;
  983.         
  984.                                 for( k = 0; k < DD->BPR; k++ )
  985.                                 {
  986.                     if (memptr<BufferEnd)
  987.                     {
  988.                                             *ptr++ = hexarray[*memptr >>  4];
  989.                                             *ptr++ = hexarray[*memptr++ & 0xf];
  990.                     }
  991.                     else
  992.                     {
  993.                         *ptr++=' ';
  994.                         *ptr++=' ';
  995.                     }
  996.         
  997.                                         if(( k >> DD->DisplaySpaces ) != (( k + 1 ) >> DD->DisplaySpaces)) *ptr++ = ' ';
  998.                                 }
  999.         
  1000.                                 Move( DD->Wnd->RPort, DD->hbx, ypos );
  1001.                 if (memptr==BufferEnd)
  1002.                     Text( DD->Wnd->RPort, TextLineBuffer, HexZeilenBreite);
  1003.                 else
  1004.                                     Text( DD->Wnd->RPort, TextLineBuffer, ( bis % DD->BPR + 1 ) * 2 + (( bis % DD->BPR - 1 + 1 ) >> DD->DisplaySpaces ));
  1005.                         }
  1006.         
  1007.                         if( DD->DisplayForm & DF_ASCII )
  1008.                         {
  1009.                                 register unsigned char *ptr = TextLineBuffer;
  1010.                                 register unsigned char *memptr = DD->FD->Mem + ( DD->SPos + endzeile ) * DD->BPR;
  1011.  
  1012.                                 for( k = 0; k < DD->BPR; k++ )
  1013.                     if (memptr<BufferEnd)
  1014.                                             *ptr++ = displaytab[ DD->DisplayTyp ][ *memptr++ ];
  1015.                     else
  1016.                         *ptr++=' ';
  1017.                                 
  1018.                                 Move( DD->Wnd->RPort, DD->abx, ypos );
  1019.                 if (memptr==BufferEnd)
  1020.                                     Text( DD->Wnd->RPort, TextLineBuffer, DD->BPR);
  1021.                 else
  1022.                                     Text( DD->Wnd->RPort, TextLineBuffer, bis % DD->BPR + 1 );
  1023.                         }
  1024.                 }
  1025.         }
  1026. }
  1027.  
  1028. /*
  1029.  */
  1030.  
  1031. void MoveDisplay( long diff, struct DisplayData *DD )
  1032. {
  1033. #ifdef DEBUG
  1034.         Printf("Diff = %ld\n", diff );
  1035. #endif
  1036.  
  1037.         if( diff > 0 )
  1038.         {
  1039.                         /* Umkopieren des gleichbleibenden Bereichs */
  1040.  
  1041.                 ClipBlit( DD->Wnd->RPort, DD->mbx, DD->bby + diff * DD->DI->fhöhe, DD->Wnd->RPort, DD->mbx, DD->bby, 9 * DD->DI->fbreite, ( DD->Zeilen - diff ) * DD->DI->fhöhe, 0xc0 );
  1042.  
  1043.                 if( DD->DisplayForm & DF_HEX )
  1044.                         ClipBlit( DD->Wnd->RPort, DD->hbx, DD->bby + diff * DD->DI->fhöhe, DD->Wnd->RPort, DD->hbx, DD->bby, (2 * DD->BPR + (( DD->BPR - 1 ) >> DD->DisplaySpaces )) * DD->DI->fbreite, ( DD->Zeilen - diff ) * DD->DI->fhöhe, 0xc0 );
  1045.  
  1046.                 if( DD->DisplayForm & DF_ASCII )
  1047.                         ClipBlit( DD->Wnd->RPort, DD->abx, DD->bby + diff * DD->DI->fhöhe, DD->Wnd->RPort, DD->abx, DD->bby, DD->BPR * DD->DI->fbreite, ( DD->Zeilen - diff ) * DD->DI->fhöhe, 0xc0 );
  1048.         }
  1049.         else
  1050.         {
  1051.                 ClipBlit( DD->Wnd->RPort, DD->mbx, DD->bby, DD->Wnd->RPort, DD->mbx, DD->bby - diff * DD->DI->fhöhe, 9 * DD->DI->fbreite, ( DD->Zeilen + diff ) * DD->DI->fhöhe, 0xc0 );
  1052.  
  1053.                 if( DD->DisplayForm & DF_HEX )
  1054.                         ClipBlit( DD->Wnd->RPort, DD->hbx, DD->bby, DD->Wnd->RPort, DD->hbx, DD->bby - diff * DD->DI->fhöhe, (2 * DD->BPR + (( DD->BPR - 1 ) >> DD->DisplaySpaces )) * DD->DI->fbreite, ( DD->Zeilen + diff ) * DD->DI->fhöhe, 0xc0 );
  1055.  
  1056.                 if( DD->DisplayForm & DF_ASCII )
  1057.                         ClipBlit( DD->Wnd->RPort, DD->abx, DD->bby, DD->Wnd->RPort, DD->abx, DD->bby - diff * DD->DI->fhöhe, DD->BPR * DD->DI->fbreite, ( DD->Zeilen + diff ) * DD->DI->fhöhe, 0xc0 );
  1058.         }
  1059. }
  1060.  
  1061. /*
  1062.  * void RedrawDisplay( struct DisplayData *DD );
  1063.  */
  1064.  
  1065. void RedrawDisplay( struct DisplayData *DD )
  1066. {
  1067.         long MaxZeilen;
  1068.  
  1069.                 /* Maximale Zeilen der Datei berechnen */
  1070.  
  1071.         MaxZeilen = ((( DD->FD->Len + DD->BPR - 1 ) / DD->BPR > DD->Zeilen) ? DD->Zeilen : ( DD->FD->Len + DD->BPR - 1 ) / DD->BPR );
  1072.  
  1073.         if( DD->FD->Len )
  1074.         {
  1075.                 DrawAddresses( 0, ( DD->Zeilen <= MaxZeilen ) ? DD->Zeilen - 1 : MaxZeilen - 1, DD );
  1076.  
  1077.                         /* Zeilen darstellen */
  1078.  
  1079.                 if( DD->Flags & DD_MARK )
  1080.                 {
  1081.                         long markstart, markend;
  1082.                         
  1083.                         if( DD->MPos < DD->CPos )
  1084.                         {
  1085.                                 markstart = DD->MPos;
  1086.                                 markend = DD->CPos;
  1087.                         }
  1088.                         else
  1089.                         {
  1090.                                 markstart = DD->CPos;
  1091.                                 markend = DD->MPos;
  1092.                         }
  1093.                         
  1094.                         markstart -= DD->SPos * DD->BPR;
  1095.                         markend -= DD->SPos * DD->BPR;
  1096.                         
  1097.                         if( markstart > 0 )
  1098.                         {
  1099.                                 SetAPen( DD->Wnd->RPort, NormalAPen );
  1100.                                 SetBPen( DD->Wnd->RPort, NormalBPen );
  1101.                                         
  1102.                                 DisplayPart( 0, markstart - 1, DD );
  1103.                         }
  1104.                         else
  1105.                                 markstart = 0;
  1106.                                                         
  1107.                         SetAPen( DD->Wnd->RPort, BlockAPen );
  1108.                         SetBPen( DD->Wnd->RPort, BlockBPen );
  1109.  
  1110.                         if( markend >= DD->BPR * DD->Zeilen )
  1111.                         {
  1112.                                 DisplayPart( markstart, DD->BPR * DD->Zeilen - 1, DD );
  1113.                         }
  1114.                         else
  1115.                         {
  1116. //                                DisplayPart( markstart, markend - 1, DD );
  1117.                 DisplayPart( markstart, markend, DD );
  1118.  
  1119.                                 {
  1120.                                         long end;
  1121.         
  1122.                                         end = DD->BPR * DD->Zeilen - 1;
  1123.                                         if( end > DD->FD->Len -  DD->BPR * DD->SPos )
  1124.                                                 end = DD->FD->Len - DD->BPR * DD->SPos-1;
  1125.  
  1126.                                         SetAPen( DD->Wnd->RPort, NormalAPen );
  1127.                                         SetBPen( DD->Wnd->RPort, NormalBPen );
  1128.                                         
  1129.                                         DisplayPart( markend + 1, end, DD );
  1130.                                 }
  1131.                         }
  1132.                 }
  1133.                 else
  1134.                 {
  1135.                         long end;
  1136.  
  1137.                         SetAPen( DD->Wnd->RPort, NormalAPen );
  1138.                         SetBPen( DD->Wnd->RPort, NormalBPen );
  1139.                                 
  1140.                         end = DD->BPR * DD->Zeilen - 1;
  1141.                                 
  1142.                         if( end > DD->FD->Len -  DD->BPR * DD->SPos )
  1143.                                 end = DD->FD->Len - DD->BPR * DD->SPos-1;
  1144.  
  1145.                         DisplayPart( 0, end, DD );
  1146.                 }
  1147.         }       
  1148.         
  1149.                 /* Ungenutzte Zeilen löschen */
  1150.  
  1151.         if( DD->Zeilen != MaxZeilen )
  1152.         {
  1153.                 if( DD->DisplayForm & DF_HEX )
  1154.                         EraseRect( DD->Wnd->RPort, DD->hbx, DD->bby + MaxZeilen * DD->DI->fhöhe, DD->hbx + (2 * DD->BPR + (( DD->BPR - 1 ) >> DD->DisplaySpaces )) * DD->DI->fbreite - 1, DD->bby + DD->Zeilen * DD->DI->fhöhe - 1 );
  1155.  
  1156.                 if( DD->DisplayForm & DF_ASCII )
  1157.                         EraseRect( DD->Wnd->RPort, DD->abx, DD->bby + MaxZeilen * DD->DI->fhöhe, DD->abx + DD->BPR * DD->DI->fbreite - 1, DD->bby + DD->Zeilen * DD->DI->fhöhe - 1 );
  1158.  
  1159.                 EraseRect( DD->Wnd->RPort, DD->mbx, DD->bby + MaxZeilen * DD->DI->fhöhe, DD->mbx + 9 * DD->DI->fbreite - 1, DD->bby + DD->Zeilen * DD->DI->fhöhe - 1 );
  1160.         }
  1161. }
  1162.  
  1163. /*
  1164.  * void RedrawPart( long von, long bis, struct DisplayData *DD )
  1165.  *
  1166.  * Stellt die Zeilen von bis neu dar.
  1167.  */
  1168.  
  1169. void RedrawPart( long von, long bis, struct DisplayData *DD )
  1170. {
  1171.         long lastline;
  1172.         long bispos = bis * DD->BPR + DD->BPR - 1, vonpos = von * DD->BPR;
  1173.  
  1174.         lastline = DD->FD->Len / DD->BPR - DD->SPos;
  1175.  
  1176. #ifdef DEBUG
  1177.         Printf("RedrawPart: v=%ld b=%ld\n", von, bis );
  1178. #endif
  1179.  
  1180.         if( DD->FD->Len )
  1181.         {
  1182.                 DrawAddresses( von, bis, DD );
  1183.  
  1184.                         /* Zeilen darstellen */
  1185.  
  1186.                 if( DD->Flags & DD_MARK )
  1187.                 {
  1188.                         long markstart, markend;
  1189.                         
  1190.                         if( DD->MPos < DD->CPos )
  1191.                         {
  1192.                                 markstart = DD->MPos;
  1193.                                 markend = DD->CPos;
  1194.                         }
  1195.                         else
  1196.                         {
  1197.                                 markstart = DD->CPos;
  1198.                                 markend = DD->MPos;
  1199.                         }
  1200.                         
  1201.                         markstart -= DD->SPos * DD->BPR;
  1202.                         markend -= DD->SPos * DD->BPR;
  1203.                         
  1204. #ifdef DEBUG
  1205.                         Printf("Markstart:%ld, Markend:%ld,VP:%ld,BP:%ld\n", markstart, markend, vonpos, bispos );
  1206. #endif
  1207.  
  1208.                         /* 5 Möglichkeiten:
  1209.                          * 1.Markbereich nicht in neuzuzeichnenden Bereich
  1210.                          * 2.Markbereich hört auf
  1211.                          * 3.Markbereich beginnt
  1212.                          * 4.Markbereich beginnt und hört auf
  1213.                          * 5.Markbereich beginnt nicht und hört auch nicht auf
  1214.                          */
  1215.                         
  1216.                         if(( markend < vonpos && markstart < vonpos ) ||
  1217.                                 ( markend > bispos && markstart > bispos ))
  1218.                         {
  1219. #ifdef DEBUG
  1220.                                 Printf("Fall 1\n");
  1221. #endif
  1222.                                 SetAPen( DD->Wnd->RPort, NormalAPen );
  1223.                                 SetBPen( DD->Wnd->RPort, NormalBPen );
  1224.                                         
  1225.                                 DisplayPart( vonpos, bispos, DD );
  1226.                         }
  1227.                         else if( markstart <= vonpos && markend < bispos )
  1228.                         {
  1229. #ifdef DEBUG
  1230.                                 Printf("Fall 2\n");
  1231. #endif
  1232.                                 SetAPen( DD->Wnd->RPort, BlockAPen );
  1233.                                 SetBPen( DD->Wnd->RPort, BlockBPen );
  1234.  
  1235.                                 DisplayPart( vonpos, markend, DD );
  1236.  
  1237.                                 SetAPen( DD->Wnd->RPort, NormalAPen );
  1238.                                 SetBPen( DD->Wnd->RPort, NormalBPen );
  1239.                                         
  1240.                                 DisplayPart( markend + 1, bispos, DD );
  1241.                         }
  1242.                         else if( markstart > vonpos && markstart <= bispos && markend >= bispos )
  1243.                         {
  1244. #ifdef DEBUG
  1245.                                 Printf("Fall 3\n");
  1246. #endif
  1247.                                 SetAPen( DD->Wnd->RPort, NormalAPen );
  1248.                                 SetBPen( DD->Wnd->RPort, NormalBPen );
  1249.                                         
  1250.                                 DisplayPart( vonpos, markstart - 1, DD );
  1251.  
  1252.                                 SetAPen( DD->Wnd->RPort, BlockAPen );
  1253.                                 SetBPen( DD->Wnd->RPort, BlockBPen );
  1254.  
  1255.                                 DisplayPart( markstart, bispos, DD );
  1256.                         }
  1257.                         else if( markstart > vonpos && markend < bispos )
  1258.                         {
  1259. #ifdef DEBUG
  1260.                                 Printf("Fall 4\n");
  1261. #endif
  1262.                                 SetAPen( DD->Wnd->RPort, NormalAPen );
  1263.                                 SetBPen( DD->Wnd->RPort, NormalBPen );
  1264.                                         
  1265.                                 DisplayPart( vonpos, markstart - 1, DD );
  1266.  
  1267.                                 SetAPen( DD->Wnd->RPort, BlockAPen );
  1268.                                 SetBPen( DD->Wnd->RPort, BlockBPen );
  1269.  
  1270.                                 DisplayPart( markstart, markend, DD );
  1271.  
  1272.                                 SetAPen( DD->Wnd->RPort, NormalAPen );
  1273.                                 SetBPen( DD->Wnd->RPort, NormalBPen );
  1274.                                         
  1275.                                 DisplayPart( markend + 1, bispos, DD );
  1276.                         }
  1277.                         else if( markstart < vonpos && markend > bispos )
  1278.                         {
  1279. #ifdef DEBUG
  1280.                                 Printf("Fall 5\n");
  1281. #endif
  1282.                                 SetAPen( DD->Wnd->RPort, BlockAPen );
  1283.                                 SetBPen( DD->Wnd->RPort, BlockBPen );
  1284.  
  1285.                                 DisplayPart( vonpos, bispos, DD );
  1286.                     }
  1287. #ifdef DEBUG
  1288.                         else
  1289.                         {
  1290.                                 Printf("Nicht möglich!\n");
  1291.                         }
  1292. #endif
  1293.                 }
  1294.                 else
  1295.                 {
  1296.                         SetAPen( DD->Wnd->RPort, NormalAPen );
  1297.                         SetBPen( DD->Wnd->RPort, NormalBPen );
  1298.                                 
  1299.                         DisplayPart( vonpos, bispos, DD );
  1300.                 }
  1301.         }
  1302.         
  1303. /*      if( DD->Zeilen != MaxZeilen )
  1304.         {
  1305.                 if( DD->DisplayForm & DF_HEX )
  1306.                         EraseRect( DD->Wnd->RPort, DD->hbx, DD->bby + MaxZeilen * DD->DI->fhöhe, DD->hbx + (2 * DD->BPR + (( DD->BPR - 1 ) >> DD->DisplaySpaces )) * DD->DI->fbreite - 1, DD->bby + DD->Zeilen * DD->DI->fhöhe - 1 );
  1307.  
  1308.                 if( DD->DisplayForm & DF_ASCII )
  1309.                         EraseRect( DD->Wnd->RPort, DD->abx, DD->bby + MaxZeilen * DD->DI->fhöhe, DD->abx + DD->BPR * DD->DI->fbreite - 1, DD->bby + DD->Zeilen * DD->DI->fhöhe - 1 );
  1310.  
  1311.                 EraseRect( DD->Wnd->RPort, DD->mbx, DD->bby + MaxZeilen * DD->DI->fhöhe, DD->mbx + 9 * DD->DI->fbreite - 1, DD->bby + DD->Zeilen * DD->DI->fhöhe - 1 );
  1312.         }*/
  1313. }
  1314.  
  1315. /*
  1316.  * void AllDisplayChar()
  1317.  *
  1318.  * Stellt ein Byte in allen Displays eines Files neu dar.
  1319.  */
  1320.  
  1321. void AllDisplayChar( struct FileData *FD, long Offset )
  1322. {
  1323.         struct DisplayData *DD;
  1324.         char text[ 2 ];
  1325.         int off, x, y;
  1326.  
  1327.         DD = GetDDFromFD( FD->DisplayList.lh_Head );
  1328.  
  1329.         while( DD != GetDDFromFD( &FD->DisplayList.lh_Tail ))
  1330.         {
  1331.                 off = Offset - DD->BPR * DD->SPos;
  1332.  
  1333.                 if(( off >= 0 ) && ( off < DD->BPR * DD->Zeilen ))
  1334.                 {
  1335.                         x = off % DD->BPR;
  1336.                         y = off / DD->BPR;
  1337.  
  1338.                         MySetWriteMask( DD->Wnd->RPort, 1 );
  1339.  
  1340.                         if( DD->DisplayForm & DF_ASCII )
  1341.                         {
  1342.                                 MyText( DD->Wnd->RPort, DD->abx + x * DD->DI->fbreite, DD->bby + y * DD->DI->fhöhe, &displaytab[ DD->DisplayTyp ][ DD->FD->Mem[ Offset ]], 1);
  1343.                         }
  1344.  
  1345.                         if( DD->DisplayForm & DF_HEX )
  1346.                         {
  1347.                                 ByteToString( DD->FD->Mem[ Offset ], text );
  1348.         
  1349.                                 x = 2 * x + ( x >> DD->DisplaySpaces );
  1350.                                 MyText( DD->Wnd->RPort, DD->hbx + x * DD->DI->fbreite, DD->bby + y * DD->DI->fhöhe, text, 2 );
  1351.                         }
  1352.  
  1353.                         MySetWriteMask(DD->Wnd->RPort,0xff);
  1354.                 }
  1355.  
  1356.                 DD = GetDDFromFD( DD->FNode.ln_Succ );
  1357.         }
  1358. }
  1359.  
  1360. /*
  1361.  * void AllDisplay()
  1362.  *
  1363.  * Stellt alle Displays eines Files neu dar.
  1364.  */
  1365.  
  1366. void AllDisplay( struct FileData *FD, long Pos )
  1367. {
  1368.         struct DisplayData *DD;
  1369.  
  1370.         DD = GetDDFromFD( FD->DisplayList.lh_Head );
  1371.  
  1372.         while( DD != GetDDFromFD( &FD->DisplayList.lh_Tail ))
  1373.         {
  1374.                 RedrawDisplay( DD );
  1375.  
  1376.                 DD = GetDDFromFD( DD->FNode.ln_Succ );
  1377.         }
  1378. }
  1379.  
  1380. /*
  1381.  * void MakeDisplay( void )
  1382.  * 
  1383.  * Window nach dem Öffnen, einer Größenänderung oder einer DisplayFormänderung
  1384.  * neu darstellen.
  1385.  * 
  1386.  * Force = TRUE erzwingt einer Neudarstellung. Im anderen Fall wird
  1387.  * geprüft, ob Zeilen und Spaltenzahl gleich bleiben und ggf. wird
  1388.  * nicht geändert.
  1389.  */
  1390.  
  1391. void MakeDisplay( struct DisplayInhalt *DI )
  1392. {
  1393.         WORD MinWidth, MinHeight;
  1394.         BOOL TooSmallX = FALSE, TooSmallY = FALSE;
  1395.  
  1396.         struct DisplayData *DD;
  1397.         long Zeilen = 0;
  1398.         long Anzahl = 0;
  1399.         BYTE DisplayForm = 0;
  1400.         long YOff;
  1401.  
  1402.         SetWaitPointer( DI->Wnd );
  1403.  
  1404.                 /* Alle Displaybereiche durchgehen */
  1405.  
  1406.         DD = ( struct DisplayData * )DI->DisplayList.lh_Head;
  1407.  
  1408.         while( DD != ( struct DisplayData * )&DI->DisplayList.lh_Tail )
  1409.         {
  1410.                 Anzahl++;
  1411.                 Zeilen += DD->Zeilen; 
  1412.  
  1413.                 if( DisplayForm < DD->DisplayForm ) 
  1414.                         DisplayForm = DD->DisplayForm;
  1415.                 
  1416.                 DD = ( struct DisplayData *)DD->Node.ln_Succ;
  1417.         }
  1418.  
  1419.                 /* Minimale Breite und Höhe des Fensters bei eigestelltem Font */
  1420.                 /* und eigestellten Displayoptionen berechnen */
  1421.  
  1422.         MinWidth = DI->Wnd->BorderLeft + DI->Wnd->BorderRight + BOXADDX + 9 * DI->fbreite;
  1423.  
  1424.         if( DisplayForm & DF_ASCII )
  1425.                 MinWidth += DI->fbreite + BOXADDX;
  1426.  
  1427.         if( DisplayForm & DF_HEX )
  1428.                 MinWidth += 2 * DI->fbreite + BOXADDX;
  1429.  
  1430.         MinHeight = DI->Wnd->BorderTop + DI->Wnd->BorderBottom;
  1431.         MinHeight += 2 * Anzahl * (DI->fhöhe + BOXADDY);
  1432.  
  1433.                 /* Prüfen, ob das Window zu klein ist? */
  1434.  
  1435.         if( DI->Wnd->Height < MinHeight )
  1436.         {
  1437.                         /* Alle Bereiche auf eine Zeile setzten */
  1438.  
  1439.                 DD = ( struct DisplayData * )DI->DisplayList.lh_Head;
  1440.                 while( DD != ( struct DisplayData * )&DI->DisplayList.lh_Tail )
  1441.                 {
  1442.                         DD->Zeilen = 1;
  1443.                 
  1444.                         DD = ( struct DisplayData *)DD->Node.ln_Succ;
  1445.                 }
  1446.  
  1447.                 if( DI->Wnd->Height != Scr->Height )
  1448.                         TooSmallY = TRUE;
  1449.         }
  1450.         else
  1451.         {
  1452.                 WORD MaxZeilen;
  1453.  
  1454.                 MaxZeilen = ( DI->Wnd->Height - MinHeight ) / DI->fhöhe + Anzahl;
  1455.  
  1456.                 if( Zeilen != MaxZeilen )
  1457.                 if( Zeilen > MaxZeilen )
  1458.                 {
  1459.                         WORD Zuviel = Zeilen - MaxZeilen;
  1460.  
  1461.                         DD = ( struct DisplayData * )DI->DisplayList.lh_TailPred;
  1462.                         
  1463.                         while( Zuviel && (DD != ( struct DisplayData *)&DI->DisplayList.lh_Head ))
  1464.                         {
  1465.                                 if( DD->Zeilen - 1 > Zuviel )
  1466.                                 {
  1467.                                         DD->Zeilen -= Zuviel;
  1468.                                         Zuviel = 0;
  1469.                                 }
  1470.                                 else
  1471.                                 {
  1472.                                         Zuviel -= DD->Zeilen - 1;
  1473.                                         DD->Zeilen = 1;
  1474.                                 }
  1475.  
  1476.                                 DD = ( struct DisplayData * )DD->Node.ln_Pred;
  1477.                         }
  1478.                 }
  1479.                 else
  1480.                 {
  1481.                         ((struct DisplayData *)DI->DisplayList.lh_TailPred)->Zeilen += MaxZeilen - Zeilen;
  1482.                 }
  1483.         }
  1484.  
  1485.         if( DI->Wnd->Width < MinWidth )
  1486.         {
  1487.                 DD->BPR = 1;
  1488.  
  1489.                 if( DI->Wnd->Width != Scr->Width )
  1490.                         TooSmallX = TRUE;
  1491.         }
  1492.         else
  1493.         {
  1494.                 WORD TempBreite;
  1495.  
  1496.                         /* Anzahl der Bytes pro Zeile für jeden Bereich berechen */
  1497.         
  1498.                 TempBreite = DI->Wnd->Width - DI->Wnd->BorderLeft - DI->Wnd->BorderRight - DI->fbreite * 9 - BOXADDX;
  1499.  
  1500.                 DD = ( struct DisplayData * )DI->DisplayList.lh_Head;
  1501.  
  1502.                 while( DD != ( struct DisplayData * )&DI->DisplayList.lh_Tail )
  1503.                 {
  1504.                         DD->BPR = TempBreite;
  1505.  
  1506.                         if( DD->DisplayForm & DF_HEX )
  1507.                                 DD->BPR -= BOXADDX;
  1508.                         
  1509.                         if( DD->DisplayForm & DF_ASCII )
  1510.                                 DD->BPR -= BOXADDX;
  1511.                         
  1512.                         DD->BPR /= DI->fbreite;
  1513.                         
  1514.                         if(( DD->DisplayForm & DF_ASCII ) && (DD->DisplayForm & DF_HEX ))
  1515.                         {
  1516.                                 long Rest;
  1517.                 
  1518.                                 Rest = DD->BPR % ( 3 * (1 << DD->DisplaySpaces) + 1 );
  1519.                                 DD->BPR = (1 << DD->DisplaySpaces) * (DD->BPR / ( 3 * (1 << DD->DisplaySpaces) + 1 ));
  1520.                 
  1521.                                 DD->BPR += Rest / 3;
  1522.                         }
  1523.                         else if( DD->DisplayForm & DF_HEX )
  1524.                         {
  1525.                                 long Rest;
  1526.                 
  1527.                                 Rest = DD->BPR % ( 2 * (1 << DD->DisplaySpaces) + 1 );
  1528.                                 DD->BPR = (1 << DD->DisplaySpaces) * (DD->BPR / ( 2 * (1 << DD->DisplaySpaces) + 1 ));
  1529.                 
  1530.                                 DD->BPR += Rest / 2;
  1531.                         }
  1532.  
  1533.                         CalcStatusZeilenBreite( DD );
  1534.  
  1535.                         DD = ( struct DisplayData *)DD->Node.ln_Succ;
  1536.                 }
  1537.         }
  1538.  
  1539.                 /* Minimale Windowausmaße neu setzen */
  1540.  
  1541.         if( TooSmallX || TooSmallY )
  1542.         {
  1543.                 ChangeWindowBox( DI->Wnd,       DI->Wnd->LeftEdge,
  1544.                                                                         DI->Wnd->TopEdge,
  1545.                                                                         TooSmallX ? MinWidth : DI->Wnd->Width,
  1546.                                                                         TooSmallY ? MinHeight : DI->Wnd->Height );
  1547.                 Delay( 5 );
  1548.         }
  1549.  
  1550.         WindowLimits( DI->Wnd, MinWidth, MinHeight, 0, 0 );
  1551.  
  1552.         YOff = DI->Wnd->BorderTop + BOXADDY/2;
  1553.  
  1554.         DD = ( struct DisplayData * )DI->DisplayList.lh_Head;
  1555.  
  1556.         while( DD != ( struct DisplayData * )&DI->DisplayList.lh_Tail )
  1557.         {
  1558.                         /* Abstand der einzelnen Displaybereiche zum linken Rand berechnen */
  1559.         
  1560.                 DD->sbx = DI->Wnd->BorderLeft + BOXADDX / 2;
  1561.                 DD->mbx = DI->Wnd->BorderLeft + BOXADDX / 2;
  1562.         
  1563.                 if( DD->DisplayForm & DF_HEX)
  1564.                         DD->hbx = DI->Wnd->BorderLeft + BOXADDX / 2 + BOXADDX + 9 * DI->fbreite;
  1565.         
  1566.                 if( DD->DisplayForm & DF_ASCII )
  1567.                 {
  1568.                         if( DD->DisplayForm & DF_HEX)
  1569.                                 DD->abx = BOXADDX + ( 2 * DD->BPR + ((( DD->BPR - 1 ) >> DD->DisplaySpaces )) + 9 ) * DI->fbreite;
  1570.                         else
  1571.                                 DD->abx = 9 * DI->fbreite;
  1572.         
  1573.                         DD->abx += BOXADDX + DI->Wnd->BorderLeft + BOXADDX / 2;
  1574.                 }
  1575.         
  1576.                         /* Y-Abstand der Displaybereiche zum oberen Fensterrahmen berechenen */
  1577.         
  1578.                 DD->sbby = YOff;
  1579.                 DD->bby = DD->sbby + BOXADDY + DI->fhöhe;
  1580.  
  1581.                 YOff += 2 * BOXADDY + ( DD->Zeilen + 1 ) * DI->fhöhe;
  1582.  
  1583.                 DD = ( struct DisplayData *)DD->Node.ln_Succ;
  1584.         }
  1585.  
  1586.                 /* Fensterinhalt löschen */
  1587.  
  1588.         EraseRect(      DI->Wnd->RPort,
  1589.                                         DI->Wnd->BorderLeft,
  1590.                                         DI->Wnd->BorderTop,
  1591.                                         DI->Wnd->Width - DI->Wnd->BorderRight - 1,
  1592.                                         DI->Wnd->Height - DI->Wnd->BorderBottom - 1 );
  1593.  
  1594.  
  1595.                 /* Scrollrand für neue Fenstergröße berechnen */
  1596.  
  1597.         SetScrollRand( realscrollrand );
  1598.  
  1599.         DD = ( struct DisplayData * )DI->DisplayList.lh_Head;
  1600.  
  1601.         while( DD != ( struct DisplayData * )&DI->DisplayList.lh_Tail )
  1602.         {
  1603.                 {
  1604.                         long TempHoehe, TempTyp;
  1605.  
  1606.                         if( DD->Node.ln_Succ == ( struct Node * )&DI->DisplayList.lh_Tail )
  1607.                         {
  1608.                                 TempHoehe = -DI->Wnd->Height + DI->Wnd->Height - 11 - DD->sbby + 1;
  1609.                                 TempTyp = GA_RelHeight;
  1610.                         }
  1611.                         else
  1612.                         {
  1613.                                 TempHoehe = (DD->Zeilen+1) * DI->fhöhe + 2 * BOXADDY - 2;
  1614.                                 TempTyp = GA_Height;
  1615.                         }
  1616.                         
  1617.                         if( DD->PropGadget )
  1618.                         {
  1619.                                 SetGadgetAttrs(DD->PropGadget,DI->Wnd,0,
  1620.                                                                         GA_Top,                 DD->sbby - 1,
  1621.                                                                         TempTyp,                        TempHoehe,
  1622.                                                         TAG_DONE);
  1623.                         }
  1624.                         else
  1625.                         {
  1626.                                 if( DD->PropGadget = ( struct Gadget * ) NewObject( NULL, "propgclass",
  1627.                                                 ICA_TARGET,             ICTARGET_IDCMP,
  1628.                                                 GA_UserData,                    DD,
  1629.                                                 GA_Top,                 DD->sbby - 1,
  1630.                                                 GA_RelRight,    -13,
  1631.                                                 GA_Width,               10,
  1632.                                                 TempTyp,                TempHoehe,
  1633.                                                 GA_RelVerify,   TRUE,
  1634.                                                 GA_Immediate,   TRUE,
  1635.                                                 PGA_Total,              1,
  1636.                                                 PGA_Top,                        0,
  1637.                                                 PGA_Visible,    1,
  1638.                                                 PGA_NewLook,    TRUE,
  1639.                                                 PGA_Borderless,Kick30 ? TRUE : FALSE,
  1640.                                                 TAG_END ))
  1641.                                         AddGadget( DI->Wnd, DD->PropGadget, 0);
  1642.                         }
  1643.                 }
  1644.                         /* Statuszeilenbevelbox zeichnen */
  1645.         
  1646.                 DrawBevelBox(DI->Wnd->RPort, DD->sbx - 4, DD->sbby - 2, DD->StatusZeilenBreite + BOXADDX, DI->fhöhe + 4, GT_VisualInfo, VisualInfo, TAG_DONE);
  1647.  
  1648.                         /* Bevelboxes zeichen */
  1649.         
  1650.                 DrawBevelBox(DI->Wnd->RPort, DD->mbx - 4, DD->bby - 2,  9 * DI->fbreite + 8, DD->Zeilen * DI->fhöhe + 4, GT_VisualInfo, VisualInfo, TAG_DONE);
  1651.                 if( DD->DisplayForm & DF_HEX )
  1652.                         DrawBevelBox(DI->Wnd->RPort, DD->hbx - 4, DD->bby - 2, (2 * DD->BPR + (( DD->BPR - 1 ) >> DD->DisplaySpaces )) * DI->fbreite + 8, DD->Zeilen * DI->fhöhe + 4, GT_VisualInfo, VisualInfo, TAG_DONE);
  1653.                 if( DD->DisplayForm & DF_ASCII )
  1654.                         DrawBevelBox(DI->Wnd->RPort, DD->abx - 4, DD->bby - 2, DD->BPR * DI->fbreite + 8, DD->Zeilen * DI->fhöhe + 4, GT_VisualInfo, VisualInfo, TAG_DONE);
  1655.  
  1656.                 /* Scroller nach Position stellen und Gadget setzen */
  1657.  
  1658.                 DD->SPos = DD->CPos / DD->BPR - DD->ScrollRand;
  1659.                 if( DD->SPos < 0 ) DD->SPos = 0;
  1660.                 SetScrollerGadget( DD );
  1661.  
  1662.                         /* Displayinhalt neu darstellen */
  1663.  
  1664.                 RedrawDisplay( DD );
  1665.  
  1666.                         /* Cursor oder Markierung neu zeichnen */
  1667.  
  1668.                 if( !( DD->Flags & DD_MARK ))
  1669.                         CursorOn( DD );
  1670.                 else
  1671.                         MarkOn( DD );
  1672.  
  1673.                 UpdateStatusZeile( DD );
  1674.  
  1675.                 DD = ( struct DisplayData *)DD->Node.ln_Succ;
  1676.         }
  1677.  
  1678.         RefreshWindowFrame( DI->Wnd );
  1679.  
  1680.         ClrWaitPointer( DI->Wnd );
  1681. }
  1682.  
  1683. long GetFitHeight( struct DisplayInhalt *DI )
  1684. {
  1685.         struct DisplayData *DD;
  1686.         WORD Anzahl = 0, Zeilen = 0;
  1687.  
  1688.         DD = ( struct DisplayData * )DI->DisplayList.lh_Head;
  1689.  
  1690.         while( DD != ( struct DisplayData * )&DI->DisplayList.lh_Tail )
  1691.         {
  1692.                 Anzahl++;
  1693.                 Zeilen += DD->Zeilen;
  1694.  
  1695.                 DD = ( struct DisplayData * )DD->Node.ln_Succ;
  1696.         }
  1697.  
  1698.         return(( Zeilen + Anzahl ) * DI->fhöhe + 2 * Anzahl * BOXADDY );
  1699. }
  1700.  
  1701. long GetFitWidth( struct DisplayInhalt *DI )
  1702. {
  1703.         struct DisplayData *DD;
  1704.         WORD MaxWidth = 0;
  1705.  
  1706.         DD = ( struct DisplayData * )DI->DisplayList.lh_Head;
  1707.  
  1708.         while( DD != ( struct DisplayData * )&DI->DisplayList.lh_Tail )
  1709.         {
  1710.                 CalcStatusZeilenBreite( DD );
  1711.  
  1712.                 if( MaxWidth < DD->StatusZeilenBreite )
  1713.                         MaxWidth = DD->StatusZeilenBreite;
  1714.  
  1715.                 DD = ( struct DisplayData * )DD->Node.ln_Succ;
  1716.         }
  1717.  
  1718.         return( MaxWidth + BOXADDX );
  1719. }
  1720.  
  1721. void AdjustWindowSize( struct DisplayInhalt *DI )
  1722. {
  1723.         if( DI->Wnd )
  1724.         {
  1725.                 ChangeWindowBox( DI->Wnd,       DI->Wnd->LeftEdge,
  1726.                                                                                         DI->Wnd->TopEdge,
  1727.                                                                                         GetFitWidth( DI ) + DI->Wnd->BorderRight + DI->Wnd->BorderLeft,
  1728.                                                                                         GetFitHeight(DI ) + DI->Wnd->BorderTop + DI->Wnd->BorderBottom );
  1729.         }
  1730. }
  1731.  
  1732. void SetStatusZeile( UBYTE *String, struct DisplayData *DD )
  1733. {
  1734.         WORD StringLaenge;
  1735.  
  1736.         StringLaenge = strlen( String );
  1737.  
  1738.         if( StringLaenge > DD->StatusZeilenBreite / DD->DI->fbreite )
  1739.                 StringLaenge = DD->StatusZeilenBreite / DD->DI->fbreite;
  1740.  
  1741.         if( DD->DI->AktuDD == DD )
  1742.                 SetAPen( DD->Wnd->RPort, 3 );
  1743.         else    
  1744.                 SetAPen( DD->Wnd->RPort, 0 );
  1745.  
  1746.         RectFill( DD->Wnd->RPort, DD->sbx - 2, DD->sbby - 1, DD->sbx - 1, DD->sbby + DD->DI->fhöhe + 1 - 1 );
  1747.         RectFill( DD->Wnd->RPort, DD->sbx - 2, DD->sbby - 1, DD->sbx + DD->StatusZeilenBreite + 2 - 1, DD->sbby - 1 );
  1748.         RectFill( DD->Wnd->RPort, DD->sbx - 2, DD->sbby + DD->DI->fhöhe + 1 - 1, DD->sbx + DD->StatusZeilenBreite + 2 - 1, DD->sbby + DD->DI->fhöhe + 1 - 1 );
  1749.         RectFill( DD->Wnd->RPort, DD->sbx - 2 + StringLaenge * DD->DI->fbreite, DD->sbby - 1, DD->sbx + DD->StatusZeilenBreite + 2 - 1, DD->sbby + DD->DI->fhöhe + 1 - 1 );
  1750.                 
  1751.         if( DD->DI->AktuDD == DD )
  1752.         {
  1753.                 SetAPen( DD->Wnd->RPort, 1 );
  1754.                 SetBPen( DD->Wnd->RPort, 3 );
  1755.         }
  1756.         else    
  1757.         {
  1758.                 SetAPen( DD->Wnd->RPort, 1 );
  1759.                 SetBPen( DD->Wnd->RPort, 0 );
  1760.         }
  1761.  
  1762.         Move( DD->Wnd->RPort, DD->sbx, DD->sbby + DD->DI->fbase );
  1763.         Text( DD->Wnd->RPort, String, StringLaenge );
  1764.  
  1765.         SetBPen( DD->Wnd->RPort, 0 );
  1766.         SetAPen( DD->Wnd->RPort, 1 );
  1767. }
  1768.  
  1769. void UpdateStatusZeile( struct DisplayData *DD )
  1770. {
  1771.         UBYTE String[256];
  1772.  
  1773.         if( DD->FD->Typ == FD_GRAB )
  1774.         {
  1775.                 char Buffer[ 3 ][ 10 ] = { "$", "$", "$" };
  1776.                 stcl_h( Buffer[ 0 ] + 1, ( long )DD->FD->Mem );
  1777.                 stcl_h( Buffer[ 1 ] + 1, ( long )DD->FD->Mem + DD->FD->Len );
  1778.                 stcl_h( Buffer[ 2 ] + 1, ( long )DD->FD->Mem + DD->CPos );
  1779.                 sprintf( String, GetStr( MSG_WINDOWTITLE_GRABMODE ), Buffer[ 2 ], Buffer[ 0 ], Buffer[ 1 ]);
  1780.         }
  1781.         else
  1782.         {
  1783.                 char Buffer[ 2 ][ 10 ] = { "$", "$" };
  1784.  
  1785.                 stcl_h( Buffer[ 0 ] + 1, DD->CPos );
  1786.                 stcl_h( Buffer[ 1 ] + 1, DD->FD->Len );
  1787.  
  1788.                 {
  1789.                         long Changes;
  1790.  
  1791.                         Changes = DD->FD->FullChanges + DD->FD->Changes + DD->FD->RedoChanges;
  1792.  
  1793.                         if( Changes ) strcpy( String, "* " );
  1794.                         else strcpy( String, "  " );
  1795.         
  1796.                         sprintf( String + 2, GetStr( MSG_WINDOWTITLE_FILEMODE ), Buffer[ 0 ], Buffer[ 1 ], DD->FD->Name );
  1797.  
  1798.                         if( !FileLoaded( DD->FD ))
  1799.                                 strcat( String, GetStr( MSG_INFO_GLOBAL_UNNAMED ));
  1800.                 }
  1801.         }
  1802.         
  1803.         SetStatusZeile( String, DD );
  1804. }
  1805.  
  1806. void SetScrollRand( short new )
  1807. {
  1808.         struct DisplayData *DD;
  1809.         struct DisplayInhalt *DI;
  1810.  
  1811.         realscrollrand = new;
  1812.  
  1813.         DI = ( struct DisplayInhalt * )DisplayInhaltList.lh_Head;
  1814.  
  1815.         while( DI != ( struct DisplayInhalt * )&DisplayInhaltList.lh_Tail )
  1816.         {
  1817.                 DD = ( struct DisplayData * ) DI->DisplayList.lh_Head;
  1818.  
  1819.                 while( DD != ( struct DisplayData * )&DI->DisplayList.lh_Tail )
  1820.                 {
  1821.                         if(( DD->Zeilen - 1 ) / 2 < realscrollrand ) DD->ScrollRand = ( DD->Zeilen - 1 ) / 2;
  1822.                         else DD->ScrollRand = realscrollrand;
  1823.  
  1824.                         DD = ( struct DisplayData *)DD->Node.ln_Succ;
  1825.                 }
  1826.  
  1827.                 DI = ( struct DisplayInhalt *)DI->Node.ln_Succ;
  1828.         }
  1829. }
  1830. /*
  1831.  * void WechselCursorBereich(void)
  1832.  *
  1833.  * Wechselt den Cursor zwischen Ascii-aktiv und Hex-aktiv
  1834.  */
  1835.  
  1836. void WechselCursorBereich( struct DisplayData *DD )
  1837. {
  1838.         if( DD->FD->Len == 0 )
  1839.                 return;
  1840.  
  1841.         CursorOff( DD );
  1842.  
  1843.         if( DD->Flags & DD_HEX )
  1844.                 DD->Flags &= ~DD_HEX;
  1845.         else
  1846.                 DD->Flags |= DD_HEX;
  1847.  
  1848.         CursorOn( DD );
  1849. }
  1850.  
  1851. BOOL MakeDisplayBigger( struct DisplayData *DD )
  1852. {
  1853.         struct DisplayData *DDT;
  1854.         BOOL Done = FALSE;
  1855.  
  1856.         DDT = ( struct DisplayData * )DD->Node.ln_Succ;
  1857.  
  1858.         while(( !Done ) && ( DDT != ( struct DisplayData * )&DD->DI->DisplayList.lh_Tail ))
  1859.         {
  1860.                 if( DDT->Zeilen > 1 )
  1861.                 {
  1862.                         DDT->Zeilen--;
  1863.                         DD->Zeilen++;
  1864.                         Done = TRUE;
  1865.                 }
  1866.  
  1867.                 DDT = ( struct DisplayData * )DDT->Node.ln_Succ;
  1868.         }
  1869.  
  1870.         if( !Done )
  1871.         {
  1872.                 DDT = ( struct DisplayData * )DD->Node.ln_Pred;
  1873.  
  1874.                 while(( !Done ) && ( DDT != ( struct DisplayData * )&DD->DI->DisplayList.lh_Head ))
  1875.                 {
  1876.                         if( DDT->Zeilen > 1 )
  1877.                         {
  1878.                                 DDT->Zeilen--;
  1879.                                 DD->Zeilen++;
  1880.                                 Done = TRUE;
  1881.                         }
  1882.  
  1883.                         DDT = ( struct DisplayData * )DDT->Node.ln_Pred;
  1884.                 }
  1885.         }
  1886.  
  1887.         if( Done )
  1888.                 MakeDisplay( DD->DI );
  1889.  
  1890.         return( Done );
  1891. }
  1892.  
  1893. void ChangeAktuView( struct DisplayData *DD )
  1894. {
  1895.         if( DD != AktuDD )
  1896.         {
  1897.                 struct DisplayData *OldDD;
  1898.                 
  1899.                 OldDD = AktuDD;
  1900.                 AktuDD = AktuDI->AktuDD = DD;
  1901.                 
  1902.                 UpdateStatusZeile( OldDD );
  1903.                 UpdateStatusZeile( AktuDD );
  1904.                 SetDisplayCheckMarks();
  1905.         }
  1906. }
  1907.  
  1908. void ActivateNextDisplay( void )
  1909. {
  1910.         struct DisplayData *DD;
  1911.  
  1912.         DD = ( struct DisplayData * )AktuDD->Node.ln_Succ;
  1913.  
  1914.         if( DD == ( struct DisplayData * )&AktuDD->DI->DisplayList.lh_Tail )
  1915.                 DD = ( struct DisplayData * )AktuDD->DI->DisplayList.lh_Head;
  1916.  
  1917.         ChangeAktuView( DD );
  1918. }
  1919.  
  1920. void ActivatePreviousDisplay( void )
  1921. {
  1922.         struct DisplayData *DD;
  1923.  
  1924.         DD = ( struct DisplayData * )AktuDD->Node.ln_Pred;
  1925.  
  1926.         if( DD == ( struct DisplayData * )&AktuDD->DI->DisplayList.lh_Head )
  1927.                 DD = ( struct DisplayData * )AktuDD->DI->DisplayList.lh_TailPred;
  1928.  
  1929.         ChangeAktuView( DD );
  1930. }
  1931.  
  1932. BOOL MakeDisplayMax( struct DisplayData *DD )
  1933. {
  1934.         struct DisplayData *DDT;
  1935.         WORD Zeilen = 0;
  1936.  
  1937.         DDT = ( struct DisplayData * )DD->DI->DisplayList.lh_Head;
  1938.  
  1939.         while( DDT != ( struct DisplayData * )&DD->DI->DisplayList.lh_Tail )
  1940.         {
  1941.                 if( DD != DDT )
  1942.                 {
  1943.                         Zeilen += DDT->Zeilen - 1;
  1944.                         DDT->Zeilen = 1;
  1945.                 }
  1946.  
  1947.                 DDT = ( struct DisplayData *)DDT->Node.ln_Succ;
  1948.         }
  1949.  
  1950.         if( Zeilen )
  1951.         {
  1952.                 DD->Zeilen += Zeilen;
  1953.                 MakeDisplay( DD->DI );
  1954.                 return( TRUE );
  1955.         }
  1956.         else
  1957.                 return( FALSE );
  1958. }
  1959.  
  1960. BOOL MakeDisplaySmaller( struct DisplayData *DD )
  1961. {
  1962.         struct DisplayData *DDT;
  1963.         BOOL Done = FALSE;
  1964.  
  1965.         if( DD->Zeilen == 1 )
  1966.                 return( FALSE );
  1967.  
  1968.         DDT = ( struct DisplayData * )DD->Node.ln_Succ;
  1969.  
  1970.         if( DDT != ( struct DisplayData * )&DD->DI->DisplayList.lh_Tail )
  1971.         {
  1972.                 DDT->Zeilen++;
  1973.                 DD->Zeilen--;
  1974.         }
  1975.         else
  1976.         {
  1977.                 DDT = ( struct DisplayData * )DD->Node.ln_Pred;
  1978.  
  1979.                 if( DDT != ( struct DisplayData * )&DD->DI->DisplayList.lh_Head )
  1980.                 {
  1981.                         DDT->Zeilen++;
  1982.                         DD->Zeilen--;
  1983.                 }
  1984.                 else
  1985.                         return( FALSE );
  1986.         }
  1987.  
  1988.         MakeDisplay( DD->DI );
  1989.  
  1990.         return( Done );
  1991. }
  1992.  
  1993. BOOL NewDisplay( BOOL Split )
  1994. {
  1995.         struct DisplayData *New;
  1996.         struct FileData *FD;
  1997.  
  1998.         if( AktuDD->Zeilen > 4 )
  1999.         {
  2000.                 if( !Split )
  2001.                 {
  2002.                         FD = AllocFD( FD_FILE );
  2003.                         strcpy( FD->Name, AktuDD->FD->Name );
  2004.                         *FilePart( FD->Name ) = 0;
  2005.                 }
  2006.                 else
  2007.                         FD = AktuDD->FD;
  2008.  
  2009.                 if( New = AllocDD( AktuDD->DI, FD ))
  2010.                 {
  2011.                         if( Split )
  2012.                         {
  2013.                                 New->CPos = AktuDD->CPos;
  2014.                                 New->SPos = AktuDD->SPos;
  2015.                                 New->DisplayForm = AktuDD->DisplayForm;
  2016.                                 New->DisplaySpaces = AktuDD->DisplaySpaces;
  2017.                         }
  2018.         
  2019.                         Remove( &New->Node );
  2020.                         Insert( &AktuDI->DisplayList, &New->Node, &AktuDD->Node );
  2021.         
  2022.                         New->Zeilen = ( AktuDD->Zeilen-1 ) / 2;
  2023.                         AktuDD->Zeilen = ( AktuDD->Zeilen ) / 2;
  2024.         
  2025.                         AktuDD = AktuDI->AktuDD = New;
  2026.         
  2027.                         SetDisplayCheckMarks();
  2028.         
  2029.                         MakeDisplay( AktuDI );
  2030.         
  2031.                         return( TRUE ); 
  2032.                 }
  2033.                 else
  2034.                         if( FD != AktuDD->FD )
  2035.                                 FreeFD( FD );
  2036.         }
  2037.         else
  2038.         {
  2039.                 if( MakeDisplayMax( AktuDD ))
  2040.                         return( NewDisplay( Split ));
  2041.                 return( FALSE );
  2042.         }
  2043. }
  2044.  
  2045. /*
  2046.  * BOOL CloseView( struct DisplayData *DD )
  2047.  *
  2048.  * Liefert TRUE, falls Fenster geschlossen wurde
  2049.  */
  2050.  
  2051. BOOL CloseView( struct DisplayData *DD, BOOL Force )
  2052. {
  2053.         struct DisplayInhalt *DI;
  2054.         BOOL LastOne = FALSE;
  2055.  
  2056.         if( Force || QuitView( 2, DD ))
  2057.         {
  2058.                 DI = DD->DI;
  2059.  
  2060.                 if( ElementZahl( &DD->DI->DisplayList ) == 1 )
  2061.                         LastOne = TRUE;
  2062.  
  2063.                         /* Falls es das letzte Display war, ganzes Fenster schließen */
  2064.  
  2065.                 if( LastOne )
  2066.                 {
  2067.                         FreeDD( DD );
  2068.  
  2069.                         LastOne = FALSE;
  2070.  
  2071.                                 /* Letztes Fenster? */
  2072.  
  2073.                         if( ElementZahl( &DisplayInhaltList ) == 1 )
  2074.                                 LastOne = TRUE;
  2075.  
  2076.                                 /* Falls aktuelles Fenster, nächstes aktivieren */
  2077.  
  2078.                         if( DI == AktuDI )
  2079.                                 ActivatePreviousWindow();
  2080.  
  2081.                         CloseFileXWindow( DI );
  2082.                         FreeDI( DI );
  2083.  
  2084.                                 /* Falls letztes Fenster, FileX beenden */
  2085.  
  2086.                         if( LastOne )
  2087.                                 mainflags |= MF_ENDE;
  2088.  
  2089.                         return( TRUE );
  2090.                 }
  2091.                 else
  2092.                 {
  2093.                                 /* Falls aktuelles Display, nächstes aktivieren */
  2094.  
  2095.                         if( DD == AktuDD )
  2096.                                 if(( struct DisplayData * )DD->DI->DisplayList.lh_Head == DD )
  2097.                                         ActivateNextDisplay();
  2098.                                 else
  2099.                                         ActivatePreviousDisplay();
  2100.  
  2101.                         FreeDD( DD );
  2102.  
  2103.                         MakeDisplay( DI );
  2104.                         return( FALSE );
  2105.                 }
  2106.         }
  2107.         else
  2108.                 return( FALSE );
  2109. }
  2110.  
  2111. BOOL CloseAktuView( void )
  2112. {
  2113.         return( CloseView( AktuDD, FALSE ));
  2114. }
  2115.  
  2116.  
  2117. BOOL CloseDIWindow( struct DisplayInhalt *DI, BOOL Force )
  2118. {
  2119.         struct DisplayData *DD, *NextDD;
  2120.         BOOL LastOne = FALSE;
  2121.  
  2122.         if( Force || QuitRequester( 1, DI ))
  2123.         {
  2124.                         /* Letztes Fenster? */
  2125.  
  2126.                 if( ElementZahl( &DisplayInhaltList ) == 1 )
  2127.                         LastOne = TRUE;
  2128.  
  2129.                 if( DI == AktuDI )
  2130.                         ActivatePreviousWindow();
  2131.  
  2132.                 DD = ( struct DisplayData * )DI->DisplayList.lh_Head;
  2133.  
  2134.                 while( DD != ( struct DisplayData * )&DI->DisplayList.lh_Tail )
  2135.                 {
  2136.                         NextDD = ( struct DisplayData * )DD->Node.ln_Succ;
  2137.         
  2138.                         FreeDD( DD );
  2139.         
  2140.                         DD = NextDD;
  2141.                 }
  2142.  
  2143.                         /* Falls es das letzte Fenster war, Programm beenden */
  2144.  
  2145.                 if( LastOne )
  2146.                         mainflags |= MF_ENDE;
  2147.  
  2148.                 CloseFileXWindow( DI );
  2149.                 FreeDI( DI );
  2150.  
  2151.                         /* Falls letztes Fenster, nichts */
  2152.                         /* Programm muß beendet oder ein DummyDisplay muß geöffnet werden */
  2153.  
  2154.                 return( TRUE );
  2155.         }
  2156.         else
  2157.                 return( FALSE );
  2158. }
  2159.  
  2160. BOOL CloseAktuWindow( void )
  2161. {
  2162.         return( CloseDIWindow( AktuDI, FALSE ));
  2163. }
  2164.  
  2165.  
  2166.